[R] Interpreting a string as a variable in a column header

rosa clements rosa.clements at somerville.oxon.net
Thu Jul 12 19:38:50 CEST 2007


This must be a very simple question, but I can't find any information
on it elsewhere, sorry. When extracting information from a list using
column headers, how do I get R to interpret something as a variable
rather than a string? For example:

xx$"YAL002"

works, but this doesn't:

gene <- "YAL002"
xx$gene

neither do

xx$parse(gene)
xx$eval(gene)
xx$eval(parse(gene))

or a variety of other constructions I have tried.

Background: I have a table of information about yeast genes, and I
also have a list of yeast genes and their GO terms (xx) from the YEAST
package that I downloaded. I want to go through all the genes in my
table and look up their GO terms in the list from the YEAST package.
They might not contain exactly the same genes (ideally they should,
but I'd be surprised if they do) and I don't think they're in the same
order, so I do want to use the column names, but there are a lot of
them so I'm not typing them all out individually. It might be possible
to turn the GO data into something other than a list, but the help
page recommends using xx <- as.list(YEASTGO) and doesn't make any
other suggestions, so I should probably do as I'm told.

Thanks for any help or suggestions of where to look,

Rosa



More information about the R-help mailing list