I have a data set with observations on groups with multiple variables. Let's call them GENO and AGE. I have control and test genotypes and two different ages. It is only meaningful to compare control and test within the same age.
I'd like to get the p value for each group compared back to control of the appropriate age. T-test requires that the grouping factor has exactly two levels. How can I do this efficiently? I was hoping something like ttest(OBS ~ GENO * AGE, mydata) would work. Is there something I can do with tapply() or aggregate() to do this? I'd like to end up with a table that looks like this: GENO Age OBS p.val control 10 1.1 1 control 10 0.9 1 control 20 2.1 1 control 20 1.9 1 A 10 11 0.01224066 A 10 9 0.01224066 A 20 21 0.003102783 A 20 19 0.003102783 B 10 4 0.057714305 B 10 6 0.057714305 B 20 14 0.005923285 B 20 16 0.005923285 AB 10 1 0.698488655 AB 10 1.1 0.698488655 AB 20 2 0.552786405 AB 20 2.2 0.552786405 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.