[R] problem about t test

Moshe Olshansky m_olshansky at yahoo.com
Fri Aug 14 05:37:48 CEST 2009


You could do the following:

y <- apply(dat,1,function(a) t.test(a[1:10],a[11:30])$p.value)

This will produce an array of 20000 p-values.

--- On Fri, 14/8/09, Gina Liao <yi713 at hotmail.com> wrote:

> From: Gina Liao <yi713 at hotmail.com>
> Subject: [R] problem about t test
> To: r-help at stat.math.ethz.ch
> Received: Friday, 14 August, 2009, 12:53 PM
> 
> Hello,
> I have a data frame >str(dat)'data.frame':  20000
> obs. of 30 variables
> it contains two information-two types of cancers:stage A(A1
> to A10) and stage B(B1 to B20)  ##totally 30
> patients-20000 sets of gene expression
> I'd like to find the lists for top 20 differentially
> expressed genes using t-test (by P-value).
> Here is my code, unfortunately it doesn't work...I need the
> help,please. I just learned R for two weeks, and hope you
> can give the hint!
> > A<-dat[,1:10] > B<-dat[,11:30]>
> bb<-function(t.test)+ { P.value.to.return <-
> t.test(A,B)$p.value+ return(P.value.to.return)+ }>
> aa<-t(apply(dat,1,bb))
> Thanks!!
> Best Regards,vie
> 
> 
> _________________________________________________________________
> 
> 
>     [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list