Class Activity

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.

Practice with lists

  1. Each of the following lists contains the vector 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))))
  1. Create a list x5 such that the vector c(2, 7, 9) can be extracted with x5[[3]][[2]][[1]].

  2. Create a list containing the following anonymous functions:

  1. Use a for loop, and the integrate function, to integrate each of the functions from question 3 between 0 and 1.