Skip to content

data.table new column := slower than base R (?) #921

Closed
@szilard

Description

While data.table new column := used to be >100x faster than base R, base R (>=3.1) updates now data.frames in place and caught up. I wonder why data.table is slower for example in this case:

library(data.table)

dt <- data.table(x = runif(100e6))
df <- as.data.frame(dt)

system.time( df$y <- 2*df$x )
system.time( dt[,y := 2*x] )

I get:

base R: 0.272 0.300 0.572 (user system elapsed)
data.table: 0.696 0.744 1.444

R 3.1.1 data.table 1.9.4.

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions