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)
> fitted(lm1)
>
> 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.
>
ave(vec,Fac)
and, yes, it can take a different function as an argument.
-thomas
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html