[R] Funny warning message
Bill Venables
wvenable at arcola.stats.adelaide.edu.au
Wed Apr 7 14:19:06 CEST 1999
>>>>> "John" == John Logsdon <j.logsdon at lancaster.ac.uk> writes:
John> So, as an entry to the wish-list, since R handles it
John> correctly, wouldn't it be better to suppress the
John> warning message - via an option statement. After all
John> t() is clearly different to t[ ] or t so the context
John> should be able to determine what is really wanted.
As it was doing, of course. All you were getting was a warning
message, which to my mind is not a bad idea. If you did use t
for a function name (and if you use it as a variable name, why
not a function?) you would probably find that some vital system
function was suddenly and mysteriously broken.
John> As a second entry to the wish-list, would it be
John> possible to set an option that ensured vector lengths
John> were strictly matched? I find that whenever I drop a
John> booboo and have mismatched vector length, the warning
(`drop' a booboo? I think the thing to avoid is making one in
the first place... :-)
John> message indicates that I have indeed done something
John> wrong. At the moment, I can't conceive of a situation
John> when an operation on two vectors where one is not the
John> same length as the other *or* one is effectively a
John> scalar (vector length 1) can be a legal statement.
John> Maybe some library functions do assume this, in which
John> case the user (or function) could store the option an
John> switch it off during the body.
John> Perhaps options(vector.match=TRUE)?
There are many situations where quite sensible programming does
make use of the recycling rule to good advantage, but I agree
that there are few (if any) cases where you need it when the
lengths are not strictly proportional. For example consider a
calculation like finding a correlation matrix (if there were not
a built-in function to do it, I know):
V <- var(X)
SD <- sqrt(diag(V))
R <- t(V/SD)/SD
Compare the last step with the operations and memory use in
R <- diag(1/SD) %*% V %*% diag(1/SD)
a style many people do adopt. Of course if V is very large,
transpostion is not a trivial operation, either.
John> Since I don't use S+, I don't know what they do but S+
John> is not the oracle anyway.
The latest version of S (version 4) outlaws vector arithmetic
with vectors of non-proportional sizes.
I think S (if not S+) is a bit of an oracle, too, by the way, and
going against the fundamental design is something that should be
done with great caution. There is a lot of occluded wisdom in S.
Bill Venables.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list