aggregatingFunction1or2()
creates statistical summaries for functions like
var()
that can have either 1 or 2 numeric vector inputs.
aggregatingFunction1or2(
fun,
output.multiple = FALSE,
na.rm = getOption("na.rm", FALSE)
)
a function that takes 1 or 2 numeric vectors and computes a summary statistic, returning a numeric vector of length 1.
a boolean indicating whether fun
returns multiple values
the default value for na.rm in the resulting function.
This was designed primarily to support var
which can be used to compute
either the variance of one variable or the covariance of two variables.
The logic of the resulting function is this: 1) If the first two arguments are both formulas,
then those formulas are evaluated (with data
) to compute the covariance;
(2) If the first argument is a formula, and the second is NULL
,
then the formula and data
are used to create the necessary call(s) to fun
;
(3) Else everything is simply passed to fun
for evaluation.