From: Bill Simpson (W.Simpson@gcal.ac.uk)
Date: Fri 22 Mar 2002 - 19:52:55 EST
Message-id: <Pine.LNX.4.10.10203220833480.5942-100000@localhost.localdomain>
I sent a similar message to R-help a few months ago with the same subject!
The basic problem is that sum doesn't automatically coerce to double,
which suprised both you and me. Thus you got integer overflow (doubles
have a much larger dynamic range so won't overflow).
If you had done sum(dep*1.0) that would
have worked as well because operations like * and / do return a double
result, and sum() on a double returns a double.
> x<-1:10
> sum(x)
[1] 55
> is.double(sum(x))
[1] FALSE
> is.double(sum(x*1))
[1] TRUE
> is.double(sum(x+0))
[1] TRUE
It's confusing to me how numbers are stored as integer:
> is.integer(x)
[1] TRUE
> is.integer(x+0)
[1] FALSE
> is.integer(x+x)
[1] TRUE
> y<-0
> is.integer(y)
[1] FALSE
> is.integer(x+y)
[1] FALSE
> y<-0:0
> is.integer(y)
[1] TRUE
> is.integer(x+y)
[1] TRUE
Bill
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2.1.3 : Wed 16 Oct 2002 - 11:57:08 EST