Skip to content
Prev 219409 / 398500 Next

how to rewrite this for loops in matrix form without loop

I believe you are trying to find the mean of x0 for each level (group) of y0.

try this:

by(x0, y0, mean)

or if you want a vector (e.g., to merge into a matrix)

c(by(x0, y0, mean))

Best regards,

Josh
On Mon, May 3, 2010 at 10:11 AM, song song <rprojecthelp at gmail.com> wrote: