Convert Nested Lists to Data Frame or Matrix in R (Example) | Apply do.call, cbind & rbind Functions

preview_player
Показать описание
R code of this video:

my_nested_list <- list(l1 = list(1:5, # Create nested list
letters[3:1],
"x"),
l2 = list(10:15,
letters[13:11],
"y"),
l3 = list("This",
"is another",
"list"))
my_nested_list # Print nested list

my_nested_list))

my_list_data_cbind$l1 # Print one element of nested list in data frame

my_nested_list)
my_list_data_rbind # Print nested list in matrix

my_list_data_rbind["l1", ] # Print one element of nested list in matrix

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Thank u for this Joachim
What if u got named nested lists and you want to convert all in a large data.frame/tibble
How would u approach it after adding an id column?

ahmedJaber
welcome to shbcf.ru