[R] odd feature
Duncan Murdoch
murdoch at stats.uwo.ca
Mon May 22 23:27:09 CEST 2006
On 5/22/2006 5:01 PM, ivo welch wrote:
> Hi Thomas:
>
>> One case where the vector-vector recycling rules are used is in
>> vector-matrix operations:
>> a<-1:4
>> b<-diag(4)
>> a+b
>
> is this last expression intended to be intuitive and thus desirable?
> if anything else, I would end up writing something like this more as
> an error than by intent. I would suggest that recycling might be
> better to be explicitly asked for by the user---though I am not sure
> what the syntax should be.
> allow.recycle(a+b)
> at the end, I think implicit recycling is a tradeoff between
> convenience and unintended errors. I would judge the convenience of
> implicit recycling to be fairly low, and the unintended error rate
> [with difficulty finding it] to be fairly high.
>
> I guess the R language has few options() that control its
> behavior---e.g., ala "use strict;" in perl. If it did, I would love
> to turn off implicit recycling, provided there is an explicit recycle
> possibility.
While I agree with you about these things in principle, this is a very
old S design decision, and I think it can't really change now. It would
have to be a local change (i.e. "in my namespace, do things strictly"),
and that's very unlikely to happen.
I would not mind having the ability to be forced to
> define variables first, either, though this is not a big deal. R is
> pretty good in telling me when I use variables that have not been
> defined.
There are some code tools around that help to detect such things.
Duncan Murdoch
More information about the R-help
mailing list