(This article was first published on

**Yet Another Blog in Statistical Computing » S+/R**, and kindly contributed to R-bloggers)data.table (http://datatable.r-forge.r-project.org/) inherits from data.frame and provides functionality in fast subset, fast grouping, and fast joins. In previous posts, it is shown that the shortest CPU time to aggregate a data.frame with 13,444 rows and 14 columns for 10 times is 0.236 seconds with summarize() in Hmisc package. However, after the conversion from data.frame to data.table, the CPU time of aggregation improves significantly, as shown in the example below.

> library(data.table) data.table 1.8.6 For help type: help("data.table") > class(df) [1] "data.frame" > dt <- data.table(df) > class(dt) [1] "data.table" "data.frame" > system.time({ + for (i in 1:10){ + summ <- dt[, list(INCOME = mean(INCOME), BAD = mean(BAD)),by = list(SELFEMPL, OWNRENT)] + } + }) user system elapsed 0.060 0.000 0.062 > print(summ) SELFEMPL OWNRENT INCOME BAD 1: 0 0 2133.314 0.08470957 2: 0 1 2881.201 0.06293210 3: 1 1 3487.910 0.05316973 4: 1 0 2742.247 0.06896552

To

**leave a comment**for the author, please follow the link and comment on his blog:**Yet Another Blog in Statistical Computing » S+/R**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...