How to Generate a List of Vectors in R (Example Code)
In this R tutorial you’ll learn how to construct a list of vectors.
Example: Apply list Function to Create List of Vectors in R
example_list <- list(l1 = LETTERS[9:4], # Constructing list of vectors l2 = 10:15, l3 = 100:93, l4 = rep(5, 5)) example_list # Displaying list of vectors in RStudio # $l1 # [1] "I" "H" "G" "F" "E" "D" # # $l2 # [1] 10 11 12 13 14 15 # # $l3 # [1] 100 99 98 97 96 95 94 93 # # $l4 # [1] 5 5 5 5 5 # |
example_list <- list(l1 = LETTERS[9:4], # Constructing list of vectors l2 = 10:15, l3 = 100:93, l4 = rep(5, 5)) example_list # Displaying list of vectors in RStudio # $l1 # [1] "I" "H" "G" "F" "E" "D" # # $l2 # [1] 10 11 12 13 14 15 # # $l3 # [1] 100 99 98 97 96 95 94 93 # # $l4 # [1] 5 5 5 5 5 #