Learn R Programming

data.table (version 1.18.2.1)

cbindlist: Column bind multiple data.tables

Description

Column bind multiple data.tables.

Usage

cbindlist(l)
  setcbindlist(l)

Value

A new data.table based on the stacked objects.

For setcbindlist, columns in the output will be shared with the input, i.e., no copy is made.

Arguments

l

list of data.tables to merge.

Details

Column bind only stacks input elements. Works like data.table, but takes list type on input. Zero-column tables in l are omitted. Tables in l should have matching row count; recycling of length-1 rows is not yet implemented. Indices of the input tables are transferred to the resulting table, as well as the key of the first keyed table.

See Also

data.table, rbindlist, setDT

Examples

Run this code
d1 = data.table(x=1:3, v1=1L, key="x")
d2 = data.table(y=3:1, v2=2L, key="y")
d3 = data.table(z=2:4, v3=3L)
cbindlist(list(d1, d2, d3))
cbindlist(list(d1, d1))
d4 = setcbindlist(list(d1))
d4[, v1:=2L]
identical(d4, d1)

Run the code above in your browser using DataLab