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))))Activity: practice with lists
Instructions:
- Work with a neighbor to answer the following questions
- To get started, download the class activity template file
- When you are finished, render the file as an HTML and submit the HTML to Canvas (let me know if you encounter any problems)
Practice with lists
- 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).
Create a list
x5such that the vectorc(2, 7, 9)can be extracted withx5[[3]][[2]][[1]].Create a list
xin R such that:
x[[1]]returns the functionmeanx[[2]]returns the functionsdx[[3]][[1]]returns the vectorc(0, 1, 2)x[[3]][[2]]returns a function which calculates the cube root