I have a list that references the names of multiple dataframes
df_list
[[1]]
[1] "df_1"
[[2]]
[1] "df_2"
....
[[10]]
[10] "df_10"
How can I run the rbind command referencing df_list so I don't have to reference every one of the 10 names.
all_df <- rbind(df_list)
Instead of
all_df <- rbind(df_1,df_2,df_3,df_4,df_5,df_6,df_7,df_8,df_9,df_10)
CodePudding user response:
Something like this may work.
Example data: a list with the name of the iris
data frame, twice.
df_list<- list("iris", "iris")
df_list
[[1]]
[1] "iris"
[[2]]
[1] "iris"
Then use as.name
to convert the strings to the variable names:
all_df <- do.call(rbind, lapply(df_list, as.name))
nrow(df)
[1] 300