Skip to content
Prev 18776 / 63461 Next

0/1 vector for indexing leads to funny behaviour (PR#8389) (maybe a documentation deficiency?)

I appreciate the explanation that some details should not appear in the 
help pages or the Introduction to R manual.

However, I am puzzled by this part of Prof Ripley's response:

TP> [...] "An Introduction to R" [...] says this about
TP> numeric indices:
TP>     2. A vector of positive integral quantities. In
TP>        this case the values in the index vector must
TP>        lie in the set {1, 2, . . . , length(x)}
TP> (This seems to commit the sin of not telling the whole truth.)

BDR> No. Zero is not a positive integer.

That's what I was trying to say: the whole truth is that numeric index 
vectors that contain positive integral quantities can also contain 
zeros.  Upon rereading this passage yet again, I think it is more 
misleading than merely incomplete: the phrasings "positive integral 
quantities", and "*must* lie in the set ..." rule out the possibility of 
the vector containing zeros.

In this Section 2.7 in "An Introduction to R", the four types of index 
vectors are introduced with "Such index vectors can be any of four 
distinct types:". There is not even a hint that other types of index 
vectors can be used (e.g., positive integral quantities and zeros).  Is 
this really correct and helpful?  (The only way that I can see that this 
section can be interpreted as correct is to claim that that the phrasing 
"can be any of four distinct types" permits the existence of other types 
that are neither described nor hinted at.  However, this interpretation 
feels more clever than helpful.)

Tony Plate
Prof Brian Ripley wrote: