do_call_rbind_withName {eatTools}R Documentation

Row bind a list while assigning names to rows

Description

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).

Usage

do_call_rbind_withName(df_list, name = names(df_list), colName)

Arguments

df_list

A list of data.frames.

name

Vector of names to fill colName. Default uses the names of df_list.

colName

A single character; name for the new column.

Value

Returns a data.frame.

Author(s)

Benjamin Becker

Examples

### 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")

[Package eatTools version 0.7.5 Index]