ST 308 QUIZ 4 QUESTIONS & VERIFIED ANSWERS
What is the idea of faceting?
Creating multiple versions of the same plot across the levels of a categorical variable.
If I had a data set with two categorical variables, say cat1 and cat2. How could I use a
facet_grid() layer to specify that the columns of the plots should correspond to the levels
of cat2 and the rows of the plots should correspond to the levels of cat2?
facet_grid(cat2~cat1)
How do you change a ggplot's theme?
Add a theme layer
What would the code below produce? for (i in 1:3){ print(i^2) }
1,4,9
When using a for loop, the values your index takes on must be consecutive integers.
False
What statement will allow you to skip an iteration of a loop?
(next)
What statement will allow you to kick out of a loop?
(break)
What function in R (from the dplyr package) is a vectorized version of if/then/else logic?
if_else()
What is the idea of faceting?
Creating multiple versions of the same plot across the levels of a categorical variable.
If I had a data set with two categorical variables, say cat1 and cat2. How could I use a
facet_grid() layer to specify that the columns of the plots should correspond to the levels
of cat2 and the rows of the plots should correspond to the levels of cat2?
facet_grid(cat2~cat1)
How do you change a ggplot's theme?
Add a theme layer
What would the code below produce? for (i in 1:3){ print(i^2) }
1,4,9
When using a for loop, the values your index takes on must be consecutive integers.
False
What statement will allow you to skip an iteration of a loop?
(next)
What statement will allow you to kick out of a loop?
(break)
What function in R (from the dplyr package) is a vectorized version of if/then/else logic?
if_else()