[R] T.test error help

Amit Patel amitrhelp at yahoo.co.uk
Thu Jul 9 15:19:35 CEST 2009


Hi I am implementing the t.test in a loop and where the data is the same i get an error message. 

Error in t.test.default(Samp3, Samp1, na.rm = TRUE, var.equal = FALSE,  : 
  data are essentially constant

The script i am using is 

for (i in 1:length(zz[,1])) {

Samp1 <- zz[i,2:17]
Samp2 <- zz[i,18:33]
Samp3 <- zz[i,34:47]
Samp4 <- zz[i,48:63] 

TTestResult[i,2] <- t.test(Samp2, Samp1, na.rm=TRUE, var.equal = FALSE, paired=FALSE, conf.level=0.95)$p.value


TTestResult[i,3] <- t.test(Samp3, Samp1, na.rm=TRUE, var.equal = FALSE, paired=FALSE, conf.level=0.95)$p.value

TTestResult[i,4] <- t.test(Samp4, Samp1, na.rm=TRUE, var.equal = FALSE, paired=FALSE, conf.level=0.95)$p.value

}

Is there a way to make my loop ignore this problem and go onto the next iteration








More information about the R-help mailing list