Hi, I have tried this with R-2.7.2 then I got > alist[['goodbye']] NULL > alist[['hi']] NULL > alist[['hello']] [1] 10 The results make sense to me thus you might want to update your R version.
chunhao B Fox wrote: > > This seems odd. When I try to look up a list element which has a space in > the name using just the first word (i.e. no spaces), it will sometimes > return the element with a space in the name and sometimes it will return > NULL. > > Try this: > > alist <- list( 'hello'=10, bye=20, 'hello world'=30, 'goodbye world'=40, > 'hi > world'=50, 'goodbye foo'=60, 'goodbye bar'=70) > Then try fetching some list elements: >> alist[['goodbye']] > NULL >> alist[['hi']] > [1] 50 >> alist[['hello']] > [1] 10 > With "goodbye" there were a couple list elements with spaces in the name, > so > it didn't return any of them. > > With "hi" there was one (and only one) element which had "hi" as the first > word: "hi world" > > With "hello" there was an actual element named "hello" > > This seems messed up and non-intuitive to say the least. > > I am doing this on R version 2.5.0 (2007-04-23) compiled on a itanium64 > and I also tried it on R version 2.5.1 (2007-06-27) on an pentium 4 ubuntu > linux > > [[alternative HTML version deleted]] > > ______________________________________________ > [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. > > -- View this message in context: http://www.nabble.com/Bug-or-feature-with-finding-a-list-element--tp19773038p19773259.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ [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.

