Hi, To extract the p values alone: lapply(split(dat1,dat1$date),function(x) TukeyHSD(aov(value~name,data=x),"name",ordered=TRUE)[[1]][4]) #$`2008-10-05` #[1] 0.1402197
#$`2008-11-05` #[1] 0.004488184 #$`2008-12-05` #[1] 0.5441151 A.K. ----- Original Message ----- From: arun <smartpink...@yahoo.com> To: raz <barvazd...@gmail.com> Cc: R help <r-help@r-project.org> Sent: Tuesday, November 13, 2012 12:57 PM Subject: Re: [R] Tukey test for subgroups in a data frame HI, Try this: dat1<-read.table(text=" date name value 10/5/2008 L 26 10/5/2008 L 30 10/5/2008 L 54 10/5/2008 L 25 10/5/2008 M 18 10/5/2008 M 21 10/5/2008 M 29 10/5/2008 M 17 11/5/2008 L 32 11/5/2008 L 35 11/5/2008 L 44 11/5/2008 L 28 11/5/2008 M 19 11/5/2008 M 22 11/5/2008 M 18 11/5/2008 M 16 12/5/2008 L 24 12/5/2008 L 33 12/5/2008 L 35 12/5/2008 L 28 12/5/2008 M 29 12/5/2008 M 23 12/5/2008 M 39 12/5/2008 M 42 ",sep="",header=TRUE,stringsAsFactors=FALSE) dat1$date<-as.Date(dat1$date,format="%m/%d/%Y") dat1<-within(dat1,{name<-factor(name)}) res<- lapply(split(dat1,dat1$date),function(x) TukeyHSD(aov(value~name,data=x),"name",ordered=TRUE)) res #$`2008-10-05` # Tukey multiple comparisons of means # 95% family-wise confidence level # factor levels have been ordered #Fit: aov(formula = value ~ name, data = x) #$name # diff lwr upr p adj #L-M 12.5 -5.501854 30.50185 0.1402197 #$`2008-11-05` # Tukey multiple comparisons of means # 95% family-wise confidence level # factor levels have been ordered #Fit: aov(formula = value ~ name, data = x) #$name # diff lwr upr p adj #L-M 16 7.13522 24.86478 0.0044882 ---------------------------------------- A.K. ----- Original Message ----- From: raz <barvazd...@gmail.com> To: r-help@r-project.org Cc: Sent: Tuesday, November 13, 2012 11:27 AM Subject: [R] Tukey test for subgroups in a data frame Hello, I have a data frame with the following columns: "date","name","value" the name is the same for each date I would like to get TukeyHSD p-value for the differences of "value" between "name"s in each "date" separately I tried different ANOVA (aov()) but can only get either tukey by "name" or by "data" but not "name by date" any suggestions? Thanks -- \m/ [[alternative HTML version deleted]] ______________________________________________ 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. ______________________________________________ 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. ______________________________________________ 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.