aveWithArgs: the ave() function but with arguments passed to FUN

Description Usage Arguments Value See Also Examples

View source: R/violinPoint.R

Description

A function is applied to subsets of x where each subset consist of those observations with the same groupings in y

Usage

1
aveWithArgs(x, y, FUN = mean, ...)

Arguments

x

a vector to apply FUN to

y

a vector or list of vectors of grouping variables all of the same length as x

FUN

function to apply for each factor level combination.

...

additional arguments to FUN

Value

A numeric vector of the same length as x where an each element contains the output from FUN after FUN was applied on the corresponding subgroup for that element (repeated if necessary within a subgroup).

See Also

ave

Examples

1
2
aveWithArgs(1:10,rep(1:5,2))
aveWithArgs(c(1:9,NA),rep(1:5,2),max,na.rm=TRUE)

Example output

 [1] 3.5 4.5 5.5 6.5 7.5 3.5 4.5 5.5 6.5 7.5
 [1] 6 7 8 9 5 6 7 8 9 5

vipor documentation built on May 1, 2019, 7:06 p.m.