Hi Vivek,
res1 <- read.table("positve-res1.txt",header=TRUE)
?dim(res1)
#[1] 5292??? 4
#You could simplify the first loop as:
mean_Res2 <- as.vector(rowMeans(res1))
?identical(mean_Res1,mean_Res2)
#[1] TRUE
##Regarding the second loop:
pval_r2 <- as.vector(apply(res1,1,function(x)
as.numeric(try(t.test(x)$p.value))))
length(pval_r2)
#[1] 5292
?sum(is.na(pval_r2))
#[1] 64
##From running your second loop
?length(pval_r1) ##stopped at the first instance where data are essentially
constant
#[1] 63
?res1[64,]
#??????????? p118_diff p132_1_diff p132_2_diff mean
#XLOC_000353???????? 1?????????? 1?????????? 1??? 1
?head(which(is.na(pval_r2)))
#[1]? 64? 78? 99 259 309 397
A.K.
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:
mean_Res1<-c()
for (i in 1:length(res1[,1]))
{
mean_Res1<-c(mean_Res1,mean(as.numeric(res1[i,])))
}
pval_r1<-NULL
for(i in 1:length(res1[,1])){
pval_r1<-c(pval_r1,t.test(as.numeric(res1[i,]))$p.value)
print(i)
}
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