[R] Error in t.test

arun smartpink111 at yahoo.com
Thu Jan 9 18:29:12 CET 2014

Hi Vivek,

res1 <- read.table("positve-res1.txt",header=TRUE)
#[1] 5292    4
#You could simplify the first loop as:
mean_Res2 <- as.vector(rowMeans(res1))
#[1] TRUE

##Regarding the second loop:

pval_r2 <- as.vector(apply(res1,1,function(x) as.numeric(try(t.test(x)$p.value))))
#[1] 5292
#[1] 64

##From running your second loop

 length(pval_r1) ##stopped at the first instance where data are essentially constant
#[1] 63
#            p118_diff p132_1_diff p132_2_diff mean
#XLOC_000353         1           1           1    1

#[1]  64  78  99 259 309 397


On Thursday, January 9, 2014 9:58 AM, Vivek Das <vd4mmind at gmail.com> wrote:

I have some query. I would be glad if you can help me out. I am trying to calculate the p-value for a simple datafram, but am getting an error. The data in each column are relative differences.. The last column being the mean. I am giving the code snippet. I am not being able to figure out  why this error is coming up. 
My matrix looks like:


for (i in 1:length(res1[,1]))


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

Error in t.test.default(as.numeric(res1[i, ])) : 
  data are essentially constant

I am not being able to figure out why is the t-test failing? Here is my matrix in the attachment. Can you suggest me?


Vivek Das

More information about the R-help mailing list