Skip to main content
United States
Jump To
Support
Register or Log In
Support
Register or Log In
Instructors
Browse Products
Getting Started
Students
Browse Products
Getting Started
Return to Research Methods Using R 1e Student Resources
Chapter 2 Multiple choice questions
Quiz Content
*
not completed
.
What is the appropriate way to request the 10
^{th}
entry of the variable
numberlist
in R?
numberlist(10)
correct
incorrect
numberlist[10]
correct
incorrect
numberlist{10}
correct
incorrect
numberlist<10>
correct
incorrect
*
not completed
.
The matrix K contains 8 row and 5 columns. How would you request the data from the 3
^{rd}
column?
K[ , 3]
correct
incorrect
K[3, ]
correct
incorrect
K[3]
correct
incorrect
K[8, 3]
correct
incorrect
*
not completed
.
Which of the following lines of code will create a loop that repeats 15 times?
for (n in 15:30){}
correct
incorrect
n <- 5; while (n < 15){n <- n + 1}
correct
incorrect
for (n in 0:15){}
correct
incorrect
for (n in 83:97){}
correct
incorrect
*
not completed
.
Which line of code correctly merges the two strings 'hap' and 'py' into a single string ('happy')?
c('hap','py')
correct
incorrect
paste('hap','py',sep='')
correct
incorrect
data.frame('hap','py')
correct
incorrect
paste('hap','py')
correct
incorrect
*
not completed
.
The median function calculates the median of a vector of numbers. Which of the following lines of code returns a median of 7?
median(c(1,3,5,7,9))
correct
incorrect
median(c(1,3,5,7,11))
correct
incorrect
median(c(3,5,7,11,13))
correct
incorrect
median(c(1,3,5,7,7,9))
correct
incorrect
*
not completed
.
If the data object 'a' contains the values 2, 4 and 6, what will be returned by the following line of code: a^3
5, 7, 9
correct
incorrect
6, 12, 18
correct
incorrect
8, 64, 216
correct
incorrect
9, 81, 729
correct
incorrect
*
not completed
.
To tell an
if
statement to execute some code when the value of
a
is greater than or equal to 10, which expression would you use?
if (a > 10)
correct
incorrect
if (a < 10)
correct
incorrect
if (a <= 10)
correct
incorrect
if (a >= 10)
correct
incorrect
*
not completed
.
Which of the following expressions is FALSE?
is.na(1/0)
correct
incorrect
is.infinite(1/0)
correct
incorrect
10>5
correct
incorrect
is.na(sqrt(-1))
correct
incorrect
*
not completed
.
Which option is the correct
R
syntax for an
if
statement that prints the value of
n
when it is greater than 10?
if (n > 10)(print(n))
correct
incorrect
if (n > 10){print(n)}
correct
incorrect
if {n > 10}(print(n))
correct
incorrect
if {n > 10}{print(n)}
correct
incorrect
*
not completed
.
The following code defines a function. What does it do?
mysteryfunction <- function(input1, input2){
numerator <- (input1 – input2)
denominator <- (input1 + input2)
output <- numerator/denominator
return(output)}
Calculates the difference between the inputs
correct
incorrect
Calculates the ratio of the two inputs
correct
incorrect
Divides the sum of the inputs by their difference
correct
incorrect
Divides the difference in inputs by their sum
correct
incorrect
Exit Quiz
Next Question
Review all Questions
Submit Quiz
Reset
Are you sure?
You have some unanswered questions. Do you really want to submit?
Back to top
Printed from , all rights reserved. © Oxford University Press, 2024
Select your Country