rbindlistn: rbindlist with names

Description Usage Arguments Examples

Description

This function implements rbindlist but adds an optional argument, names, which allows us to keep the names of each sub-list which we rbindlist-ify.

Usage

1
rbindlistn(l, names = ".Names")

Arguments

l

A list of data.frames, data.tables or data.frame shaped lists.

names

If names is:

  • FALSE: Do not generate a vector of names.

  • TRUE: Generate a vector of names called .Names, and append it to the data.table generated by rbindlist.

  • A string: Generate a vector of names called names, and append it to the data.table generated by rbindlist.

Examples

1
2
3
4
5
6
7
dfs <- list( a=data.frame(x=1, y=2, z=3), b=data.frame(x=4, y=5, z=6) )
rbindlistn(dfs)
lists <- list( a=list(x=1, y=2, z=3), b=list(x=4, y=5, z=6) )
rbindlistn(lists)
df1 <- data.frame(x = 1, y = 2)
df2 <- data.frame(x = 3, y = 4)
rbindlistn(list(df1, df2))

kevinushey/data.table.extras documentation built on May 20, 2019, 9:09 a.m.