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")

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

Further Resources

In the following, you can find some further resources that are similar to the content of this post.

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed