[R] vector-factor operation
tlumley at u.washington.edu
Fri Apr 14 18:09:00 CEST 2006
On Fri, 14 Apr 2006, Murray Jorgensen wrote:
> I found myself wanting to average a vector [vec] within each level of a
> factor [Fac], returning a vector of the same length as vec. After a
> while I realised that
> lm1 <- lm(vec ~ Fac)
> did what I want.
> But there must be another way to do this, and it would be good to be
> able to apply other functions than mean() in this way.
and, yes, it can take a different function as an argument.
More information about the R-help