[R] seq() in 0.62.4 and 0.63
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Sat Nov 14 11:38:15 CET 1998
Prof Brian D Ripley <ripley at stats.ox.ac.uk> writes:
> Solaris 2.6, R Version 0.63.0 (November 14, 1998)
> Version 0.62.4 (October 24, 1998)
>
> > seq(0.15, 0.70, 0.05)
> [1] 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65
>
> The much reviled (on r-help) 0.62.3 got such simple cases right (even if
> 0.62.1 did not).
Argh!!!! We've been discussing alternative ways of getting seq right,
but didn't get around to follow it through.
> although I suspect eps is actually rather too small for safety (I would
> suggest 10 x machine precision to allow for a number of lfoating point
> operations).
The : operator already uses 1e-7... (just like S does)
> However, I think there is a much simpler approach:
>
> n <- as.integer(n + 0.1) # make sure n is not too small
> tol <- abs(to - from) * 10 * .Machine$double.eps
> if(by > 0) while(from + n*by > to + tol) n <- n - 1
> else while(from + n*by < to - tol) n <- n - 1
I've been advocating by*(from/by):(to/by), so as to have the fuzz-fix
in one place, and:
> .05*(.15/.05):(.70/.05)
[1] 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70
Of course one needs to get the sign things right as well...
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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