see ?tapply, for example:

tapply(df$x, df$z, mean)

Might also look at ?ave and ?aggregate depending on what form you want the result to have... or the "plyr" package on CRAN. Lots of options!


stat4u wrote:
hi,
How can i calculate means with catergory of variable...

like

x   y    z
2   3    y
3   4    n
1   2    y
6   3    n
9   1    y
2   2    n
8   3    y

i want to get mean of x and y with respective to  its category(y,n)

thanks...
regards,
Muhammad Faisal

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to