ST 308 QUIZ 1 QUESTIONS & VERIFIED ANSWERS
mtcars is a built in data set in R. You can obtain the column names of a data frame
using the names() function.
True or false: gear is one of the columns.
True
What is the name of the R function we discussed that will compactly display the internal
structure of an R object?
Simply give the name of the function as your answer (case sensitive). For instance, if
the answer is the 'hist' function, simply answer:
hist
str
If you want to look at the help documentation for the "hist" function, what code can you
submit to the console?
Type the entire line of code as your answer.
help(hist)
How many rows and columns does the built-in iris dataset have? Hint: Use one of the
functions that help you understand your R objects.
150 rows, 5 columns
When you create an object in an R session, in which pane of the RStudio IDE can you
see the object?
the environment pane
TRUE or FALSE: Each time you type final_answer into the console, R has to execute
the log and exp functions.
false
If you look at the help file for a function and see an argument in the function definition
with an = sign and a value next to it, for example runif(n, min = 0, max = 1), what does
the value to the right of the equal sign represent?
If the user doesn't specify a value for that argument, this is the default value to use.
, There is a built-in R object called (note that R is case-sensitive):
letters
What is the class of the letters object?
Simply give the name of the class as your answer (case sensitive, no quotes). For
instance, if the answer is the "plot", simply answer:
plot
character
In the above console, type print(cars) on one line and print(exp) on another. Submit the
code.
Why does print(cars) produce a different type of output than print(exp)?
R is determining how to use print() based on the type of object used as the input
What is the purpose of the R console?
The console is where
code is submitted to be evaluated.
What is the easiest way to save your code for later use?
Write it in an R Script or R Markdown file
What class of object is returned if you run the code iris[2, ]?
Put the name of the class of object as your answer.
data frame
What is one way to access the second element of myList and have it be returned as a
vector?
myList[[2]]
Write the R syntax for printing out a sequence of numbers from 1 to 21, by increments
of 4. Do not include any spaces in your submission.
seq(from=1,to=21,by=4)
What syntax would you use to return the third element of vec?
vec[3]
mtcars is a built in data set in R. You can obtain the column names of a data frame
using the names() function.
True or false: gear is one of the columns.
True
What is the name of the R function we discussed that will compactly display the internal
structure of an R object?
Simply give the name of the function as your answer (case sensitive). For instance, if
the answer is the 'hist' function, simply answer:
hist
str
If you want to look at the help documentation for the "hist" function, what code can you
submit to the console?
Type the entire line of code as your answer.
help(hist)
How many rows and columns does the built-in iris dataset have? Hint: Use one of the
functions that help you understand your R objects.
150 rows, 5 columns
When you create an object in an R session, in which pane of the RStudio IDE can you
see the object?
the environment pane
TRUE or FALSE: Each time you type final_answer into the console, R has to execute
the log and exp functions.
false
If you look at the help file for a function and see an argument in the function definition
with an = sign and a value next to it, for example runif(n, min = 0, max = 1), what does
the value to the right of the equal sign represent?
If the user doesn't specify a value for that argument, this is the default value to use.
, There is a built-in R object called (note that R is case-sensitive):
letters
What is the class of the letters object?
Simply give the name of the class as your answer (case sensitive, no quotes). For
instance, if the answer is the "plot", simply answer:
plot
character
In the above console, type print(cars) on one line and print(exp) on another. Submit the
code.
Why does print(cars) produce a different type of output than print(exp)?
R is determining how to use print() based on the type of object used as the input
What is the purpose of the R console?
The console is where
code is submitted to be evaluated.
What is the easiest way to save your code for later use?
Write it in an R Script or R Markdown file
What class of object is returned if you run the code iris[2, ]?
Put the name of the class of object as your answer.
data frame
What is one way to access the second element of myList and have it be returned as a
vector?
myList[[2]]
Write the R syntax for printing out a sequence of numbers from 1 to 21, by increments
of 4. Do not include any spaces in your submission.
seq(from=1,to=21,by=4)
What syntax would you use to return the third element of vec?
vec[3]