Learn R Programming

Laurae (version 0.0.0.9001)

setDF: Convert data.table to data.frame without copy

Description

This function allows to coerce a data.table to a data.frame without making in-memory copy. Therefore, you do not need 3x your current memory to coerce to a data.frame from a data.table.

Usage

setDF(x)

Arguments

x
Type: data.table. The data.table to convert to data.frame.

Value

Nothing (the data.table is transformed to a data.frame already)

Examples

Run this code
library(data.table)
df <- data.frame(matrix(nrow = 100, ncol = 10))
coln <- colnames(df)
rown <- rownames(df)
setDT(df)
is.data.table(df) # Returns TRUE = OK
sum(c(coln == colnames(df), c(rown == rownames(df)))) # Returns 2 = OK
setDF(df)
is.data.table(df) # Returns FALSE = OK
sum(c(coln == colnames(df), c(rown == rownames(df)))) # Returns 2 = OK

Run the code above in your browser using DataLab