dtagg {rchemo}R Documentation

Summary statistics of data subsets

Description

Faster alternative to aggregate to calculate a summary statistic over data subsets. dtagg uses function data.table of package data.table.

Usage


dtagg(formula, data, FUN = mean, ...)

Arguments

formula

A left and right-hand-sides formula defing the variable and the aggregation levels on which is calculated the statistic.

data

A dataframe.

FUN

Function defining the statistic to compute (default to mean).

...

Eventual additional arguments to pass through FUN.

Value

A dataframe, with the values of the agregation level(s) and the corresponding computed statistic value.

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)

dtagg(y1 ~ 1, data = dat)

dtagg(y1 ~ typ1 + typ2, data = dat)

dtagg(y1 ~ typ1 + typ2, data = dat, trim = .2)


[Package rchemo version 0.1-1 Index]