Exercise

Create a list

Just like a grocery list, lists in R can be used to hold together items of different data types. Creating a list is, you guessed it, as simple as using the list() function. You could say that a list is a kind of super data type: you can store practically any piece of information in it! Create a list like so:

words <- c("I <3 R")
numbers <- c(42, 24)

my_list <- list(words, numbers)

my_list

[[1]]
[1] "I <3 R"

[[2]]
[1] 42 24

Below, you will create your first list from some of the data you have already worked with!

Instructions

100 XP
  • The 4 components for your list have been created for you.
  • Use list() to create a list of name, apple, ibm, and cor_matrix, in that order, and assign it to portfolio.
  • Print your portfolio.