Convert Nested Lists to Data Frame or Matrix in R (Example) | Apply do.call, cbind & rbind Functions
How to store a list of lists in a data frame or matrix in the R programming language. More details: https://statisticsglobe.com/convert-nested-lists-to-data-frame-in-r 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_list_data_cbind <- as.data.frame(do.call(cbind, # Convert nested list to data frame by column my_nested_list)) my_list_data_cbind$l1 # Print one element of nested list in data frame my_list_data_rbind <- do.call(rbind, # Convert nested list to matrix by row 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: Facebook – Statistics Globe Page: https://www.facebook.com/statisticsglobecom/ Facebook – Group for Discussions & Questions: https://www.facebook.com/groups/statisticsglobe LinkedIn – Statistics Globe Page: https://www.linkedin.com/company/statisticsglobe/ LinkedIn – Group for Discussions & Questions: https://www.linkedin.com/groups/12555223/ Twitter: https://twitter.com/JoachimSchork Music by bensound.com
Download
0 formatsNo download links available.