dtaggregate | R Documentation |
Calculation of summary statistics with data subsets using function data.table
of package data.table
. The function is generally faster than aggregate
.
dtaggregate(formula, data, FUN = mean, ...)
formula |
A left and right-hand-sides formula defing the variable and the aggregation levels on which is calculated the statistic. |
data |
A data frame. |
FUN |
Function defining the statistic to compute (default to |
... |
Eventual additional arguments to pass through |
A data.frame, see the examples.
dat <- data.frame(matrix(rnorm(2 * 100), ncol = 2))
names(dat) <- c("y1", "y2")
dat$typ1 <- sample(1:2, size = nrow(dat), TRUE)
dat$typ2 <- sample(1:3, size = nrow(dat), TRUE)
headm(dat)
dtaggregate(y1 ~ 1, data = dat)
dtaggregate(y1 ~ typ1 + typ2, data = dat)
dtaggregate(y1 ~ typ1 + typ2, data = dat, trim = .2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.