DT2mat: data.table to matrix

Description Usage Arguments Details Value Examples

Description

This function coerces a data.table to a matrix using the least possible memory.

Usage

1
DT2mat(DT, low_mem = FALSE, collect = 0, silent = TRUE)

Arguments

DT

Type: data.table (or a data.frame, partially supported). The data.table to coerce to matrix.

low_mem

Type: boolean. Unallows DT twice in memory by modifying DT in place. (WARNING: empties your DT) to save memory when set to TRUE. Setting it to FALSE allow DT to reside twice in memory, therefore memory usage increases. Defaults to FALSE.

collect

Type: integer. Forces a garbage collect every collect iterations to clear up memory. Setting this to 1 along with low_mem = TRUE leads to the lowest possible memory usage one can ever get to merge two data.tables. It also prints verbose information about the process everytime it garbage collects. Setting this to 0 leads to no garbage collect. Lower values increases the time required to bind the data.tables. Defauls to 0.

silent

Type: boolean. Force silence during garbage collection iterations at no speed cost. Defaults to TRUE.

Details

Warning: DT is a pointer only and is directly modified.

Value

A matrix.

Examples

1
2
3
library(data.table)
df <- data.table(matrix(1:50000000, nrow = 50000))
mat <- DT2mat(df, low_mem = TRUE, collect = 50, silent = FALSE)

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