This is Quiz 3 from the R Programming course within the Data Science Specialization.
1. What is produced at the end of this snippet of R code?
set.seed(1)
rpois(5, 2)
## [1] 1 1 2 4 1
set.seed(1)
rpois(5, 2)
## [1] 1 1 2 4 1
2. What R function can be used to generate standard Normal random variables?
rnorm(10, 0, 1)
## [1] 1.272429321 0.414641434 -1.539950042 -0.928567035 -0.294720447
## [6] -0.005767173 2.404653389 0.763593461 -0.799009249 -1.147657009
3. When simulating data, why is using the set.seed() function important? Select all that apply.
Set.seed allows other to get the same psuedorandom sequence to verify results.
set.seed(22)
4. Which function can be used to evaluate the inverse cumulative distribution function for the Poisson distribution?
See documentation ?qpois
5. What does the following code do?
set.seed(10)
x <- rep(0:1, each = 5)
e <- rnorm(10, 0, 20)
y <- 0.5 + 2 * x + e
6. What R function can be used to generate Binomial random variables?
7. What aspect of the R runtime does the profiler keep track of when an R expression is evaluated?
8. Consider the following R code
library(datasets) Rprof() fit <- lm(y ~ x1 + x2) Rprof(NULL)
9. When using ‘system.time()’, what is the user time?
10. If a computer has more than one available processor and R is able to take advantage of that, then which of the following is true when using ‘system.time()’?
Check out my website at: http://www.ryantillis.com/