[Rd] proposal for "strict" versions of subsetting operators

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Oct 28 18:25:26 MET 2003


You would need at least a fuzz for computed indices being slightly 
non-integer (although the calling code should do that).

I can think of several cases where the implicit floor() is convenient.
Can you tell me of examples where users would do this by accident (or out 
of non-RTFM)?

On Tue, 28 Oct 2003, Ben Bolker wrote:

> 
>   On a related topic: is there any chance/any interest in a slight 
> modification of the subsetting code that would generate a warning when the 
> user tried to subset with a non-integer?  The current behavior is that the 
> non-integer is coerced to an integer, which means that e.g. x[3.8] is 
> equivalent to x[3].  I can't think of (or find in the documentation) any 
> time when this would actually be a desired behavior.
>   The only integer-testing behavior that I can find in the code base is in 
> some of the discrete-distribution code ...

Yes, but then they are documented that way, and selection is documented to 
do as.integer().

>   I might be able to hack this myself -- it looks as though ExtractSubset 
> in subset.c might be the place to do this ...
> 
>    Ben Bolker
> 
> 
> 

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list