Lists

Want to learn more? I recommend working through: R for Data Science, R Cookbook, and R Graphics Cookbook.

Lists are objects whose elements can be anything, from matrices to functions.

# Create a numeric vector
x <- runif(50)
# Create a character string vector
y <- state.name
# Create a matrix
m <- matrix(c(3, 2, 4, 3), nrow= 2)
# Create a list containing all of the above
l <- list(x, y, m)
# You can name each element in a list
names(l) <- c("percent voted", "state", "vote matrix")