[R] Problem indexing a factor variable
Ahmed, Rizwan
rizwan.ahmed at csc.mrc.ac.uk
Wed Sep 21 22:00:48 CEST 2011
Hi,
I have a dataframe "gexp_1" with 115 rows of samples and 27000 columns of gene expression measurements with each column corresponding to one gene. I now have a smaller vector of genes "tp" for which I need to pull out the data form the data frame.
# first gene from the list with 16 genes
x <- tp[1,]
x
[1] geneA
16 Levels: geneA, geneB...
#unsuccessful
gexp_1$x
NULL
#or
gexp_1$x[1]
NULL
#but this works
gexp_1$geneA
I am sure that this is a fundamental error on my part since I am new to R, I would appreciate any advice. I am trying to construct a for loop to analyze data for sets of genes at a time but stuck at this step.
Regards
Rizwan
More information about the R-help
mailing list