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

my1stbox my1stbox at 163.com
Tue Aug 26 03:26:10 CEST 2014


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
	[[alternative HTML version deleted]]



More information about the R-help mailing list