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 ______________________________________________ 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.