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: [email protected] 
> [mailto:[email protected]] On Behalf Of Ning Ma
> Sent: Thursday, 27 August 2009 3:35 p.m.
> To: [email protected]
> 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.
> 
> ______________________________________________
> [email protected] 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.
> 

______________________________________________
[email protected] 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.

Reply via email to