[R] Calculate t.test for a matrix

David Winsemius dwinsemius at comcast.net
Sat Apr 14 23:35:15 CEST 2012


On Apr 14, 2012, at 4:44 PM, Junyu Lee wrote:

> Hello everyone,
>
>
>
> I posted a question this morning, when I got replies, I realized  
> that the
> data I posted was messy.  So I am going to re-post
>

It's still a mess.

> Here is my data frame:
>

Learn to use dput:

dfrm <-
structure(list(group = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 3L, 3L, 3L, 3L), .Label = c("Control", "Test1", "Test2"), class =  
"factor"),
     gene1 = c(28.9776, 28.9499, 29.5468, 29.5246, 29.1864, 29.2048,
     34.9563, 34.9464, 36.9566, 37.1309, 36.1017, 36.0883), gene2 =  
c(9.9355,
     10.0997, 14.2995, 13.9561, 9.7718, 10.0388, 11.9509, 11.8909,
     14.5316, 14.5188, 29.5468, 29.5246)), .Names = c("group",
"gene1", "gene2"), class = "data.frame", row.names = c(NA, -12L))

> I need to calculated t.test:
>
> for gene1: test1 vs control  (29.1864, 29.2048, 34.9563,
> 34.9464) vs (28.9776, 28.9499, 29.5468, 29.5246)
>
> and          test2 vs control  (36.9566, 37.1309, 36.1017, 36.0883)
> vs (28.9776, 28.9499, 29.5468, 29.5246) .
>
> Then I'd like to perform the same on gene 2.

You appear  resistant to the notion that you may not have firm grasp  
on the statistical issues. Such hubris is at the root of quite a bit  
of published material that geneticists are cranking out that is not  
reproducible. This should be a more stiatically principled first step  
before ad hoc tests.

lapply( dfrm[ , c("gene1", "gene2"}], function(x) summary(lm(x ~  
dfrm[["group"]]) ) )


p.s. your offlist comment was amusing, but hardly accurate.

>
>
> I'm sorry for the mess

Then don't create more of them. Read the Posting Guide and heed its  
advice.

> and thank you all in advance.
>
>
> Junyu
>
> 	[[alternative HTML version deleted]]

HTML posting is a sign that you are not reading the Positn Guide.

-- 

David Winsemius, MD, MPH
West Hartford, CT



More information about the R-help mailing list