Tena koe Try either L[foo()] or L[[foo()]]
These return subtly (or not so subtly depending on your point of view) different results. HTH .... Peter Alspach > -----Original Message----- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Ning Ma > Sent: Thursday, 27 August 2009 3:35 p.m. > To: r-help@r-project.org > Subject: [R] how to index a list with a string? > > Hi, everybody. I have a list obj L, sth like > > $`aaa` > [1] "5753" > > if the string 'aaa' is a returned value of a function foo(). > what is the right syntax form of L$foo() > > I'm new to R, thanks in advance. > > ______________________________________________ > 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.