| simApply {simFrame} | R Documentation |
Generic functions for applying a function to subsets of a data set.
simApply(x, design, fun, ...) simSapply(x, design, fun, ..., simplify = TRUE)
x |
the data.frame to be subsetted. |
design |
a character, logical or numeric vector specifying the variables (columns) used for subsetting. |
fun |
a function to be applied to the subsets. |
simplify |
a logical indicating whether the results should be simplified to a vector or matrix (if possible). |
... |
additional arguments to be passed to fun. |
For simApply a data.frame.
For simSapply, a list, vector or matrix (see sapply).
Andreas Alfons, alfons@statistik.tuwien.ac.at
data(eusilc)
eusilc <- eusilc[, c("region", "gender", "eqIncome")]
## returns data.frame
simApply(eusilc, c("region", "gender"),
function(x) median(x$eqIncome))
## returns vector
simSapply(eusilc, c("region", "gender"),
function(x) median(x$eqIncome))