Skip to content

spline bug ?

2 messages · FWR, Martin Maechler

FWR
#
The bug reported above for "spline" is probably related to a similar problem with sequencing in POSIX dates.
For example this works ok:
[1]  1  2  3  4 

But the following gives an output length of five, not four:
[1] "2000-01-01 07:00:00 EST" "2000-01-02 01:00:00 EST"
[3] "2000-01-02 19:00:00 EST" "2000-01-03 13:00:00 EST"
[5] "2000-01-04 07:00:00 EST"

Surely this is a bug?

Bruce L.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Bruce> The bug reported above for "spline" is probably related to a similar problem with sequencing in POSIX dates.
    Bruce> For example this works ok:
    >> seq(from=1,to=4,out.length=4)
    Bruce> [1]  1  2  3  4 

    Bruce> But the following gives an output length of five, not four:
    >> seq(from=ISOdate(2000,1,1),to=ISOdate(2000,1,4),length.out=4)
    Bruce> [1] "2000-01-01 07:00:00 EST" "2000-01-02 01:00:00 EST"
    Bruce> [3] "2000-01-02 19:00:00 EST" "2000-01-03 13:00:00 EST"
    Bruce> [5] "2000-01-04 07:00:00 EST"

    Bruce> Surely this is a bug?

indeed.  Thanks a lot for reducing the problem so far!

The bug is in  seq.POSIXct()
and here is the fix -- soon to appear in "R-patched"  snapshots.

Index: src/library/base/R/datetime.R
===================================================================
RCS file: /home/rdevel/CVS-ARCHIVE/R/src/library/base/R/datetime.R,v
retrieving revision 1.35.2.1
retrieving revision 1.35.2.2
diff -w -r1.35.2.1 -r1.35.2.2
461,462c461,464
<         incr <- (to - from)/length.out
<         res <- seq.default(from, to, incr)
---
Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._