Learn R Programming

Laurae (version 0.0.0.9001)

DT2mat: data.table to matrix

Description

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

Usage

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.

Value

A matrix.

Details

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

Examples

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

Run the code above in your browser using DataLab