combine_df | R Documentation |
This function combines dataframes that are nested within a list of lists into a single dataframe.
combine_df(nested_list)
nested_list |
A list of lists, where each sublist contains dataframes to be combined. |
The function first checks if the input is a non-empty list of lists containing dataframes. It then iterates through each sublist, combining the dataframes and adding an ID column to indicate their source. Finally, all combined dataframes are row-bound into a single dataframe.
A combined dataframe where each original dataframe is augmented with an ID column indicating its source list.
df1 <- data.frame(a = 1:3, b = 4:6)
df2 <- data.frame(a = 7:9, b = 10:12)
nested_list <- list(list(df1, df2), list(df1, df2))
combine_df(nested_list)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.