Skip to content

help text for ave()

1 message · Henrik Pärn

#
Dear R developers,

In the help text for ave() you can read in Arguments section:

"... Grouping variables, typically factors, all of the same length as x"

...and in Value: "If ... is g1,g2,".

I think a description in the Arguments section of how two or more 
grouping variables is specified together with an Example would be very 
helpful.

In absence of a help text I just tried if the equivalent specification 
in tapply would work:

data(warpbreaks)
str(warpbreaks)
'data.frame':   54 obs. of  3 variables:
  $ breaks : num  26 30 54 25 70 52 51 26 67 18 ...
  $ wool   : Factor w/ 2 levels "A","B": 1 1 1 1 1 1 1 1 1 1 ...
  $ tension: Factor w/ 3 levels "L","M","H": 1 1 1 1 1 1 1 1 1 2 ...

ave(x = breaks, list(wool, tension), FUN = median)

Is this THE way to specify two or more grouping variables in ave()? If 
yes, maybe it could be used as an example.


Thank you all for your great work developing R!