Regarding the problem of getting the mean of auth.sum corresponding to those values of datecat==1 and a separate mean corresponding to those values of datecat==2 where auth.sum and datecat are in data frame hcd.df, here are two solutions: 1. USE BY attach(hcd.df) by(auth.sum,datecat,mean) or replace the second line with c(by(auth.sum,datecat,mean)) depending on how you like the result 2. USE LM lm(auth.sum~factor(datecat)-1,hcd.df)$coef --- Message-id: <Pine.LNX.4.21L1.0201092341260.5798-100000@nujoma.perrins> I''d like to get summary statistics (really just a mean would be fine) for a vector in a data frame, but split based on the value of another vector. That is, I have a data frame (hcd.df) with variables datecat (which is always 1 or 2) and auth.sum (-8..+8). I''ve used xtabs to get chi-square comparisons, but what I need now is a simple mean of auth.sum where datecat is 1 and another where datecat is 2. Thanks for any advice. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._