Lab 1: Dr. Arbuthnot’s Baptism Records in R
12 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the correct syntax to add lines while plotting data in R?

  • plot( x = arbuthnot$year, y = arbuthnot$girls, add.lines = 'yes')
  • plot( x = arbuthnot$year, y = arbuthnot$girls, connect = 'lines')
  • plot( x = arbuthnot$year, y = arbuthnot$girls, type = 'l') (correct)
  • plot( x = arbuthnot$year, y = arbuthnot$girls, lines = TRUE)
  • How can all possible arguments for a function in R be found?

  • Exploring the settings menu in RStudio
  • Looking at a reference manual for R functions
  • Typing 'help(plot)' in the console
  • Using the question mark followed by the function name (correct)
  • What operation can be used as an argument in the plot function to represent the total number of baptisms each year?

  • Exponentiation
  • Subtraction
  • Multiplication
  • Addition (correct)
  • Which arithmetic operation can be used to plot the total number of baptisms in 1629 in R?

    <ul> <li></li> </ul> Signup and view all the answers

    In R, what is the purpose of using the 'type' argument when plotting data?

    <p>To control the type of plot (points, lines, both)</p> Signup and view all the answers

    What functionality do the up and down arrow keys provide in RStudio?

    <p>Navigate through previous commands (command history)</p> Signup and view all the answers

    What is the correct R command to extract the counts of boys baptized from the 'arbuthnot' dataset?

    <p>arbuthnot$boys</p> Signup and view all the answers

    Which of the following commands would return the number of rows (observations) in the 'arbuthnot' dataset?

    <p>nrow(arbuthnot)</p> Signup and view all the answers

    Assuming 'arbuthnot' is a data frame, which of the following expressions is NOT a valid way to access the column names?

    <p>arbuthnot[1,]</p> Signup and view all the answers

    What does the output '82 3' from the 'dim(arbuthnot)' command represent?

    <p>82 rows and 3 columns</p> Signup and view all the answers

    If the 'arbuthnot' dataset contains 82 observations, what is the index of the last entry in the 'arbuthnot$boys' vector?

    <p>82</p> Signup and view all the answers

    Which of the following statements about R vectors is incorrect?

    <p>Vectors can contain elements of different data types.</p> Signup and view all the answers

    Study Notes

    Plotting Data in R

    • Use the lines() function to add lines to a plot.
    • The plot() function allows for various operations such as summing yearly baptisms via tapply() and aggregate().
    • To represent total baptisms each year, use the sum operation (sum) as a function argument in plot().
    • For plotting total baptisms in 1629, use the subset operation (arbuthnot$boys[arbuthnot$year == 1629]).

    Function Arguments in R

    • The args() function can be used to find all possible arguments for a given function in R.

    Purpose of the 'type' Argument

    • The 'type' argument in the plot() function specifies the type of plot (e.g., point, line, or both) that will be displayed.

    RStudio Functionalities

    • Up and down arrow keys in RStudio allow users to navigate through command history for easy access to previously executed commands.

    Accessing Data in Datasets

    • Use arbuthnot$boys to extract the counts of boys baptized from the 'arbuthnot' dataset.
    • nrow(arbuthnot) command returns the number of rows (observations) in the 'arbuthnot' dataset.
    • Common expressions to access column names include colnames(arbuthnot) and names(arbuthnot); expressions like arbuthnot[1] are NOT valid.

    Dimensions of the Dataset

    • The output '82 3' from dim(arbuthnot) indicates the dataset has 82 observations (rows) and 3 variables (columns).

    Data Indexing in R

    • If 'arbuthnot' contains 82 observations, the last entry in the 'arbuthnot$boys' vector is indexed at 82.

    R Vectors

    • Key concept: R vectors can store multiple values, but an incorrect statement regarding their properties would not conform to how vectors function (e.g., vectors being able to contain mixed data types).

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Learn how to access Dr. Arbuthnot’s baptism records data in R by using the source() function. Explore the dataset that contains 83 observations and 3 variables, focusing on the ratio of girls and boys. Understand how to display all observations with column titles and check the dimensions of the table with dim().

    More Like This

    Use Quizgecko on...
    Browser
    Browser