Skip to content
Prev 343412 / 398506 Next

How to do t.test to rows of a dataframe using apply family function?

Hi All?
How to do t.test  to rows (with two levels, or in other words, groups of samples) of a dataframe using apply family function? I have done that using function and loops. And my overall purpose is to calculate DE genes from two groups of miRNA microarray samples. And I know limma can do that, but it seems limma doesn't support paired t-test.

t.test.df=function(df,paired){
  df.t=c()
  for(i in 1:nrow(df)){
    df.t=rbind(df.t,unlist(t.test(df[i,grp1],df[i,grp2],paired=paired)))
  }
  rownames(df.t)=rownames(df)
  df.t
}

Bests!
Allen Chiu

2014-08-26