Learn R Programming

Laurae (version 0.0.0.9001)

cbindlist: data.table column list binding

Description

This function attempts to replicate rbindlist for columns.

Usage

cbindlist(target)

Arguments

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

Value

A data.table based on target.

Examples

Run this code
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

Run the code above in your browser using DataLab