[Rd] Problematic sentence in Section 6.1 (Lists) of "An introduction to R" (PR#10583)

michael.hoehle at gmail.com michael.hoehle at gmail.com
Thu Jan 17 20:50:33 CET 2008


Full_Name: Michael Höhle
Version: 2.7.0
OS: Mac Os X 10.4.11
Submission from: (NULL) (84.153.81.41)


Dear R developers,

this is not really a bug, but I was confused by the following sentence in
Section 6.1 on lists in "An introduction to R" available from e.g.
http://cran.r-project.org/doc/manuals/R-intro.html#Lists-and-data-frames

Here it says that:

Additionally, one can also use the names of the list components in double square
brackets, i.e., Lst[["name"]] is the same as Lst$name. 
                              ^^^^^^^^^^^
In the above context this might be right, but if one operates with named lists
the $ notation handles abbrevations, whereas the [[]] notation does not.
As a consequence I was surprised by the following code:

control <- list(nameSpace=1) 
if (is.null(control$name)) control$name <- TRUE

Here control$name is recognized as control$nameSpace and thus control$name is
assigned the value TRUE. Had one used control[["name"]] then things would have
worked differently.  Thus Lst[["name"]] might not be the same as Lst$name. 

I admit the entire case might be pedantic, but maybe an extra sentence could
help.
Just a suggestion.



More information about the R-devel mailing list