Correct: Congratulations! You Passed!
Correct: Congratulations! You Passed!
Quiz, 20 questions
20/20 points (100%)
Congratulations! You passed!
Next Item
Question 1
Correct
1 / 1 points
1. Question 1
R was developed by statisticians working at
Correct
The R language was developed by Ross Ihaka and Robert Gentleman who were statisticians
at the University of Auckland in New Zealand.
Bell Labs
Harvard University
StatSci
Question 2
Correct
1 / 1 points
2. Question 2
The definition of free software consists of four freedoms (freedoms 0 through 3). Which of
the following is NOT one of the freedoms that are part of the definition? Select all that apply.
The freedom to prevent users from using the software for undesirable purposes.
Correct
This is not part of the free software definition. Freedom 0 requires that the users of free
software be free to use the software for any purpose.
Un-selected is correct
The freedom to study how the program works, and adapt it to your needs.
Un-selected is correct
The freedom to restrict access to the source code for the software.
Correct
This is not part of the free software definition. Freedoms 1 and 3 require access to the
source code.
Un-selected is correct
The freedom to improve the program, and release your improvements to the public, so that
the whole community benefits.
Un-selected is correct
The freedom to sell the software for any price.
Correct
This is not part of the free software definition. The free software definition does not mention
anything about selling software (although it does not disallow it).
Question 3
Correct
1 / 1 points
3. Question 3
In R the following are all atomic data types EXCEPT: (Select all that apply)
numeric
Un-selected is correct
matrix
Correct
'matrix' is not an atomic data type in R.
list
Correct
'list' is not an atomic data type in R.
table
Correct
'table' is not an atomic data type in R.
logical
Un-selected is correct
character
Un-selected is correct
array
Correct
'array' is not an atomic data type in R.
data frame
Correct
'data frame' is not an atomic data type in R.
complex
Un-selected is correct
integer
Un-selected is correct
Question 4
Correct
1 / 1 points
4. Question 4
If I execute the expression x <- 4 in R, what is the class of the object `x' as determined by the
`class()' function?
real
integer
list
matrix
complex
numeric
Correct
vector
Question 5
Correct
1 / 1 points
5. Question 5
What is the class of the object defined by the expression x <- c(4, "a", TRUE)?
mixed
integer
numeric
logical
character
Correct
The character class is the "lowest common denominator" here and so all elements will be
coerced into that class.
Question 6
Correct
1 / 1 points
6. Question 6
If I have two vectors x <- c(1,3, 5) and y <- c(3, 2, 10), what is produced by the expression
cbind(x, y)?
a vector of length 2
a 2 by 2 matrix
Correct
The 'cbind' function treats vectors as if they were columns of a matrix. It then takes those
vectors and binds them together column-wise to create a matrix.
a 3 by 3 matrix
a vector of length 3
a 2 by 3 matrix
Question 7
Correct
1 / 1 points
7. Question 7
A key property of vectors in R is that
Correct
elements of a vector can be of different classes
Question 8
Correct
1 / 1 points
8. Question 8
Suppose I have a list defined as x <- list(2, "a", "b", TRUE). What does x[[1]] give me? Select
all that apply.
Correct
a numeric vector containing the element 2.
Correct
a character vector containing the element "2".
Un-selected is correct
a list containing the number 2.
Un-selected is correct
a list containing a numeric vector of length 1.
Un-selected is correct
Question 9
Correct
1 / 1 points
9. Question 9
Suppose I have a vector x <- 1:4 and a vector y <- 2. What is produced by the expression x +
y?
Correct
a numeric vector with elements 3, 2, 3, 6.
Question 10
Correct
1 / 1 points
10. Question 10
Suppose I have a vector x <- c(17, 14, 4, 5, 13, 12, 10) and I want to set all elements of this
vector that are greater than 10 to be equal to 4. What R code achieves this? Select all that
apply.
x[x == 4] > 10
Un-selected is correct
x[x >= 10] <- 4
Un-selected is correct
x[x > 4] <- 10
Un-selected is correct
x[x >= 11] <- 4
Correct
You can create a logical vector with the expression x >= 11 and then use the [ operator to
subset the original vector x.
Un-selected is correct
x[x == 10] <- 4
Un-selected is correct
x[x < 10] <- 4
Un-selected is correct
x[x > 10] <- 4
Correct
You can create a logical vector with the expression x > 10 and then use the [ operator to
subset the original vector x.
Question 11
Correct
1 / 1 points
11. Question 11
Use the Week 1 Quiz Data Set to answer questions 11-20.
In the dataset provided for this Quiz, what are the column names of the dataset?
1, 2, 3, 4, 5, 6
Correct
You can get the column names of a data frame with the `names()' function.
Question 12
Correct
1 / 1 points
12. Question 12
Extract the first 2 rows of the data frame and print them to the console. What does the output
look like?
1
2
3
Ozone Solar.R Wind Temp Month Day
1 9 24 10.9 71 9 14
2 18 131 8.0 76 9 29
1
2
3
Ozone Solar.R Wind Temp Month Day
1 7 NA 6.9 74 5 11
2 35 274 10.3 82 7 17
1
2
3
Ozone Solar.R Wind Temp Month Day
1 18 224 13.8 67 9 17
2 NA 258 9.7 81 7 22
1
2
3
Ozone Solar.R Wind Temp Month Day
1 41 190 7.4 67 5 1
2 36 118 8.0 72 5 2
Correct
You can extract the first two rows using the [ operator and an integer sequence to index the
rows.
Question 13
Correct
1 / 1 points
13. Question 13
How many observations (i.e. rows) are in this data frame?
153
Correct
You can use the `nrows()' function to compute the number of rows in a data frame.
160
129
45
Question 14
Correct
1 / 1 points
14. Question 14
Extract the last 2 rows of the data frame and print them to the console. What does the output
look like?
1
2
3
Ozone Solar.R Wind Temp Month Day
152 31 244 10.9 78 8 19
153 29 127 9.7 82 6 7
1
2
3
Ozone Solar.R Wind Temp Month Day
152 11 44 9.7 62 5 20
153 108 223 8.0 85 7 25
1
2
3
Ozone Solar.R Wind Temp Month Day
152 18 131 8.0 76 9 29
153 20 223 11.5 68 9 30
Correct
The `tail()' function is an easy way to extract the last few elements of an R object.
1
2
3
Ozone Solar.R Wind Temp Month Day
152 34 307 12.0 66 5 17
153 13 27 10.3 76 9 18
Question 15
Correct
1 / 1 points
15. Question 15
What is the value of Ozone in the 47th row?
21
Correct
The single bracket [ operator can be used to extract individual rows of a data frame.
63
18
34
Question 16
Correct
1 / 1 points
16. Question 16
How many missing values are in the Ozone column of this data frame?
43
37
Correct
The `is.na' function can be used to test for missing values.
78
Question 17
Correct
1 / 1 points
17. Question 17
What is the mean of the Ozone column in this dataset? Exclude missing values (coded as
NA) from this calculation.
18.0
53.2
42.1
Correct
The `mean' function can be used to calculate the mean.
31.5
Question 18
Correct
1 / 1 points
18. Question 18
Extract the subset of rows of the data frame where Ozone values are above 31 and Temp
values are above 90. What is the mean of Solar.R in this subset?
334.0
205.0
185.9
212.8
Correct
You need to construct a logical vector in R to match the question's requirements. Then use
that logical vector to subset the data frame.
Question 19
Correct
1 / 1 points
19. Question 19
What is the mean of "Temp" when "Month" is equal to 6?
79.1
Correct
90.2
85.6
75.3
Question 20
Correct
1 / 1 points
20. Question 20
What was the maximum ozone value in the month of May (i.e. Month is equal to 5)?
97
115
Correct
18
100