powered by
Use do.call(rbind, ...) on a list of data.frames while creating a new variable (colName) which contains, for example, the original list naming (name).
do.call(rbind, ...)
data.frames
colName
name
do_call_rbind_withName(df_list, name = names(df_list), colName)
Returns a data.frame.
data.frame
A list of data.frames.
Vector of names to fill colName. Default uses the names of df_list.
df_list
A single character; name for the new column.
Benjamin Becker
### create example list df_list <- lapply(mtcars, function(x) { data.frame(m = mean(x), sd = sd(x)) }) ### transform to a single data.frame do_call_rbind_withName(df_list, colName = "variable")
Run the code above in your browser using DataLab