Gang Chen-3 wrote: > > Sorry to hijack this thread. I have a similar but slightly different > situation. Using the original poster's example, how to elegantly get > the mean of column V2 when column V1 is either A or C and F1 is 0? > >
I am not sure if this is elegant, but it works: a=mean(mydat$V2[mydat$F1==0 & mydat$V1 %in% ("A","C")]) -- View this message in context: http://www.nabble.com/Getting-mean-in-a-dataframe-tf4801030.html#a13736727 Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.