Two-Dimensional Array of Vectors with Different Lengths in R (Example Code)
This article explains how to construct a matrix of list objects in the R programming language.
Exemplifying Data
list_a <- list(10:5) # Create three lists in R list_b <- list(5, 3, 1) list_c <- list("a", "xyz", "b") |
list_a <- list(10:5) # Create three lists in R list_b <- list(5, 3, 1) list_c <- list("a", "xyz", "b")
Example: Insert Multiple Lists in Matrix Object
list_matrix <- matrix(list(list_a, list_b, list_c), # Store lists in matrix ncol = 1) list_matrix # Display matrix of lists # [,1] # [1,] list,1 # [2,] list,3 # [3,] list,3 |
list_matrix <- matrix(list(list_a, list_b, list_c), # Store lists in matrix ncol = 1) list_matrix # Display matrix of lists # [,1] # [1,] list,1 # [2,] list,3 # [3,] list,3
Further Resources
In the following, you can find some further resources that are similar to the content of this post.