Lists in R
A list is like a super data type that can hold any other data type inside it.
# Vector with numerics from 12 up to 100
my_vector <- 12:100
# Matrix with numerics from 1 up to 8
my_matrix <- matrix(1:8, ncol = 2)
# First 13 elements of the built-in data frame mtcars
my_df <- mtcars[1:13,]
# Construct list with these different elements:
my_list <- list(my_vector, my_matrix, my_df)
my_list <- list(name1 = your_comp1,
name2 = your_comp2)
The above code can be understood from:
shining_list <- list(moviename = movie, actors = actor, reviews = review)
It contains three elements:
moviename: a character string with the movie title (stored in mov) actors: a vector with the main actors' names (stored in act) reviews: a data frame that contains some reviews (stored in rev)
my_list <- list(my_vector, my_matrix, my_df)
names(my_list) <- c("vec","mat","df")