Dear All, I apologize for this trivial question, I can not find the solution I try to use t.test function per line in the data.frame, But i dont'understand the error message my program is as follows group1<-gl(2,20) fun<-function(x){ m<-data.frame(group1,x) #anova(aov(x ~ group1, m)) t.est(x ~ group1,m) } ttest<- apply(data, 1, fun) Error in t.test.default(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : data are essentially constant Any help would be appreciated ML Best -- Mohamed Lajnef,IE INSERM U955 eq 15 P?le de Psychiatrie H?pital CHENEVIER 40, rue Mesly 94010 CRETEIL Cedex FRANCE Mohamed.lajnef at inserm.fr tel : 01 49 81 31 31 (poste 18470) Sec : 01 49 81 32 90 fax : 01 49 81 30 99
Mohamed Lajnef wrote:> Dear All, > > I apologize for this trivial question, I can not find the solution > I try to use t.test function per line in the data.frame, But i > dont'understand the error message > > my program is as follows > > group1<-gl(2,20) > fun<-function(x){ > m<-data.frame(group1,x) > #anova(aov(x ~ group1, m)) > t.est(x ~ group1,m) > }Are you sure this is your code? What is t.est? What is m? Please provide a reproducible example.> > ttest<- apply(data, 1, fun) > Error in t.test.default(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : > data are essentially constantWhat is data? The error is explained in the help page, which says: If the input data are effectively constant (compared to the larger of the two means) an error is generated. It looks like your input data are all '1' as shown in the error message.
On May 5, 2010, at 12:15 PM, Mohamed Lajnef wrote:> Dear All, > > I apologize for this trivial question, I can not find the solution > I try to use t.test function per line in the data.frame, But i > dont'understand the error message > > my program is as follows > > group1<-gl(2,20) > fun<-function(x){ > m<-data.frame(group1,x) > #anova(aov(x ~ group1, m)) > t.est(x ~ group1,m) > } > > ttest<- apply(data, 1, fun) > Error in t.test.default(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, > 1, 1, : > data are essentially constant >You apparently think x has some variablity. R does not. what does tapply(x group1, sd) show?> > Any help would be appreciated > > ML > Best > > > > -- > > > Mohamed Lajnef,IE INSERM U955 eq 15 > P?le de Psychiatrie > H?pital CHENEVIER > 40, rue Mesly > 94010 CRETEIL Cedex FRANCE > Mohamed.lajnef at inserm.fr > tel : 01 49 81 31 31 (poste 18470) > Sec : 01 49 81 32 90 > fax : 01 49 81 30 99 > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT