On Thu, Feb 10, 2005 at 01:35:56PM -0000, michael watson (IAH-C) wrote: > I have a variable that contains the following numerical text "04010". > This is the name to access a list: > > > as.list(KEGGPATHID2NAME)$"04010" > [1] "MAPK signaling pathway" > > Marvellous! Except I want to do that when "04010" is assigned to a > variable called path and I can't figure out how to do it! > > > path <- "04010" > > > > # the original and best > > as.list(KEGGPATHID2NAME)$"04010" > [1] "MAPK signaling pathway" > > > > # clearly this doesn't, and shouldn't, work > > as.list(KEGGPATHID2NAME)$path > NULL
$ allows only a literal character string or a symbol as the index, according to the R language definition, but [[ indexing does the same as $ and can be used for computed indexing. So as.list(KEGGPATHID2NAME)[[path]] should do what you want. Greetinx, Jan -- +- Jan T. Kim -------------------------------------------------------+ | *NEW* email: [EMAIL PROTECTED] | | *NEW* WWW: http://www.cmp.uea.ac.uk/people/jtk | *-----=< hierarchical systems are for files, not for humans >=-----* ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html