<- rep(NA, 100) x
Class activity solutions
<- rep(0, 3) x
<- seq(0, 3, 0.01) x
<- seq(0, 3, 0.01)
x 23] x[
[1] 0.22
<- seq(0, 3, 0.01)
x <- rep(NA, length(x))
sqrt_x for(i in 1:length(x)){
<- sqrt(x[i])
sqrt_x[i] }
<- seq(0, 3, 0.01)
x <- sqrt(x) sqrt_x
<- sample(1:100, 10, replace=FALSE) x
<- sample(-2:2, 10, replace=TRUE) x
<- rnorm(1000, mean=3, sd=sqrt(11)) x
<- function(n, beta0, beta1){
exp_model <- rnorm(n)
x <- beta0 * x^beta1
y plot(x, y)
}
<- function(n, beta0, beta1){
exp_model <- rnorm(n)
x <- beta0 * x^beta1
y return(list(x, y))
}
- There are many possible solutions; here is one example:
<- list("a", list("a", c(2, 7, 9)))
x 2]][[2]] x[[
[1] 2 7 9
Because
x[1]
is a list (containing a function), not a function
<- list(function(n){return(rnorm(n, mean=0, sd=3))},
x function(n){return(runif(n, min=0, max=1))})
1]](10) x[[
[1] -2.09638329 -1.08370156 -3.68404755 3.75592101 6.01960072 0.29506038
[7] 0.05672882 4.32535667 -2.88014427 -2.68932223