cbindlist: data.table column list binding

Description Usage Arguments Value Examples

Description

This function attempts to replicate rbindlist for columns.

Usage

1
cbindlist(target)

Arguments

target

Type: list. A list to perform cbindlist on, with vectors only.

Value

A data.table based on target.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(data.table)

# Create named junk list
mega_list <- list(a = rnorm(1000),
                  b = rnorm(1000),
                  c = rnorm(1000),
                  d = rnorm(1000),
                  e = rnorm(1000),
                  f = rnorm(1000),
                  g = rnorm(1000))

# Perform cbindlist, equivalent of rbindlist but for columns, accepting only vectors
my_dt <- cbindlist(mega_list)

# Check column name correctness/coverage
sum(colnames(my_dt) == c("a", "b", "c", "d", "e", "f", "g")) / 7 # 100% coverage

Laurae2/Laurae documentation built on May 8, 2019, 7:59 p.m.