On Mon, Dec 1, 2008 at 12:53 PM, Reitsma, Rene - COB
<[EMAIL PROTECTED]> wrote:
> Dear All,
>
> I'm hoping one of you can help me with the following R problem. I'm
> trying to refer to a member of a list by variable. However, this seems
> not to work:
>
> foo=list(first=c(1:10),second=c(11:20))
>
>> foo$first
>  [1]  1  2  3  4  5  6  7  8  9 10
>
>> foo$"first"
>  [1]  1  2  3  4  5  6  7  8  9 10
>
>> goo=c("first")
>
>> foo$goo
> NULL
>
>> foo$goo[1]
> NULL
>

foo[[goo]]

which you'll find in ?"$" under the heading "Recursive (list-like) objects"

Hadley

-- 
http://had.co.nz/

______________________________________________
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.

Reply via email to