[R] Is it a bug in list() behavior?
ligges at statistik.uni-dortmund.de
Mon Mar 24 19:31:37 CET 2003
Tony Plate wrote:
> As wolski/Eryk's example shows, it seems that "[[" for lists accepts abbreviations, whereas "[" does not. Is this intended? (This is a difference from S-plus - both "[" and "[[" for lists accept abbreviations in S-plus (V6.1 for Windows at least.)
The general subscripting operator  doesn't support abbreviations at
all. I don't know of any reference that states  supports partial
matching of character strings.
> I couldn't find any mention of this difference in regards to accepting abbreviations in either ?"[" or section 6.1 of the Introduction to R, or in the R Language Manual, or in the R Reference Manual. [As an aside, I'd rather that the subset operators didn't accept abbreviations at all,but ...]
[] is the component extractor for lists, and the reference I gave
tells us that partial matching works for component indexing.
I agree that it's a good idea to mention this behaviour in the R
Language *Definition* manual.
> The name returned by "[" for a non-existent element of a list also seems of dubious correctness.
>  123
Everything as expected from my point of view. Do you mean the "NA" is
See the R Language Definition, Section 3.4.1:
"Notice however, that there are different modes of NA—the literal
constant is of mode "logical", but it is frequently automatically
coerced to other types."
Remember, it's a name!
>  123
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> major 1
> minor 6.2
> year 2003
> month 01
> day 10
> language R
> At Monday 04:54 PM 3/24/2003 +0100, you wrote:
>>>I had assumed that the names in a list are like a keys in a hash.
>>>Therefore i thought that no value should be returned.
>>>The behavior of:
>>>is as i expected.
>>>Should it be as it is? How is the definition of [] and ?
>>No! See "An Introduction to R", Section 6.1:
>>"The names of components may be abbreviated down to the minimum number of letters needed to identify them uniquely. Thus Lst$coefficients may be minimally specified as Lst$coe and Lst$covariance as Lst$cov."
>>R-help at stat.math.ethz.ch mailing list
> R-help at stat.math.ethz.ch mailing list
More information about the R-help