Loss of attributes from arithmetic comparisons

Martyn Plummer plummer@iarc.fr
Thu, 19 Nov 1998 18:34:15 +0100


More on attributes, but nothing to do with the "[" thread...

Arithmetic comparisons strip attributes in R.  This is
incompatible with S. It is not so easy to see what the right
thing to do is here, but perhaps we should have S compatibility?

Martyn

S-PLUS 3.2
==========
S> x_1:10
S> attr(x,"foo") <- TRUE
S> x
 [1]  1  2  3  4  5  6  7  8  9 10
attr(, "foo"):
[1] T
S> x <= 5
 [1] T T T T T F F F F F
attr(, "foo"):
[1] T

R 0.63
======
R> x_1:10
R> attr(x,"foo") <- TRUE
R> x
 [1]  1  2  3  4  5  6  7  8  9 10
attr(,"foo")
[1] TRUE
R> x <= 5
 [1]  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE
R> attributes(x<=5)
NULL
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._