Re: [R] apply a function over a factor

2009-12-29 Thread Dimitris Rizopoulos
have a look at ?ave(), e.g., A - 1:10 B - factor(c(1,2,2,4,4,4,7,7,7,7)) ave(A, B) I hope it helps. Best, Dimitris farida...@gmail.com wrote: Dear R experts, I would like to substitute the values of a vector, say A, with the average values taken over a factor For example, lets assume

Re: [R] apply a function over a factor

2009-12-29 Thread Farida Mostajabi
Thanks! That's what I need. On Tue, Dec 29, 2009 at 1:33 PM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: have a look at ?ave(), e.g., A - 1:10 B - factor(c(1,2,2,4,4,4,7,7,7,7)) ave(A, B) I hope it helps. Best, Dimitris farida...@gmail.com wrote: Dear R experts, I