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 -- View this message in context: http://www.nabble.com/How-to-calculate--tp20516515p20516515.html Sent from the R help mailing list archive at Nabble.com.
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