do_call_rbind_withName | R Documentation |
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_withName(df_list, name = names(df_list), colName)
df_list |
A list of |
name |
Vector of names to fill |
colName |
A single character; name for the new column. |
Returns a data.frame
.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.