Skip to content

subsetting of factor

3 messages · Hui-Yi Chu, Adaikalavan Ramasamy

#
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: