If you use the shortcut $ then R will use partial matching to hunt for the
list element you mean.
l$fo will also match.

l[["foo"]]
will not match - the full subsetting construct doesn't use partial matching.

I think the intro to R covers this, and you can also see
?"$"
?"[["

Sarah

On Monday, March 25, 2013, Andrew Lin wrote:

> Hi folks,
>
> I am starter for R. While I tried list as following:
>
> > l <- list()
> > l$foo
> NULL
> > l$foobar <- 1
> > l$foo
> [1] 1
>
> Apparently, foo and foobar are different name for elements in list
> (actually
> foo does not exist). But why they are sharing same value?
>
> Thanks a lot!
>
> Max
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org <javascript:;> 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.
>


-- 
Sarah Goslee
http://www.stringpage.com
http://www.sarahgoslee.com
http://www.functionaldiversity.org

	[[alternative HTML version deleted]]

