To create a nested list of different lengths and convert it to a dataframe in R, you can use the following steps:
main.r292 chars13 lines
However, please note that the resulting dataframe will have NA values in the shorter lists because R will try to match the length of all lists.
If you want to convert a nested list to a dataframe where each inner list is a separate row, you can use the following code:
main.r399 chars13 lines
In this case, the "values" column will be a character column with comma-separated values.
Alternatively, you can also use the tidyverse package and unnest function from the tidyr package to convert the nested list to a dataframe:
main.r431 chars17 lines
In this case, the resulting dataframe will have separate rows for each value in the inner lists.
gistlibby LogSnag