Instructions: Work with a neighbor to answer the following questions, then we will discuss the activity as a class. To get started, download the class activity template file.
c(2, 7, 9)
. Determine the correct list indexing syntax to extract that vector from the list (your code should return just the vector, not a list containing the vector).x1 <- list(c(2, 7, 9))
x2 <- list(list(c(2, 7, 9)))
x3 <- list(c(2, 7, 9), list("a", "b"))
x4 <- list(c("a", "b"), list(list(c(2, 7, 9))))
Create a list x5
such that the vector c(2, 7, 9)
can be extracted with x5[[3]][[2]][[1]]
.
Create a list containing the following anonymous functions:
function(x) {return(x^2 - x)}
function(x) {return(sin(x) + cos(x))}
function(x) {return(exp(x)/x)}
for
loop, and the integrate
function, to integrate each of the functions from question 3 between 0 and 1.