help(rowttests) says that fac needs to be a factor. So how about ?

  m <- matrix( rnorm(30), nc=6 )
  genotype <- c("a", "a", "b", "b", "c", "c")

  w1 <- which( genotype %in% c("a", "b") )
  w2 <- which( genotype %in% c("a", "c") )
  w3 <- which( genotype %in% c("b", "c") )

  list( ab = rowttests( m[ , w1], factor( genotype[w1] ) ),
        ac = rowttests( m[ , w2], factor( genotype[w2] ) ),
        bc = rowttests( m[ , w3], factor( genotype[w3] ) ) )

Regards, Adai



Hui-Yi Chu wrote:
Dear R list,

I think my question maybe easy for you but I really spent entire day to
resolve it.
Say I have a matrix, rows are 6000 genes, columns(1-6) are 3 genotypes
(a,b,c) with 2 repeat.
I have to use two groups each time for t-test, a vs. c or b vs. c, but I
dont know how to write correct codes.
Below is my codes, the last two lines are needed to be corrected....

library("genefilter")
ef <- exprs(esetsub)
kk <- factor(esetsub$genotype == c("a", "c"))
tt <- rowttests(ef[,c(1,2,5,6)], kk)

ps.  column 1-6 is a,a,b,b,c,c
      depending on the document, the kk should be a factor..

Any suggestions are really appreciated!!

Best regards,
Hui-Yi

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

______________________________________________
R-help@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.

Reply via email to