It certainly appears that you just _did_ use it as such. You got a
spline. The only error thrown was from predict() and I think that was
because you needed to use a bit of extra coercion.
> predict(sp, x=as.numeric(as.POSIXct("2008-08-02")))
$x
[1] 1217649600
$y
[1] -0.4748701
attr(,"class")
[1] "xyVector"
--
David Winsemius
On Feb 25, 2009, at 9:30 PM, Remko Duursma wrote:
Dear R-helpers,
can I use a POSIXct date as the x variable in interpSpline? The help
page says x and y need to be numeric... is there a workaround?
example:
library(splines)
testdfr <-
data.frame(Date=seq(as.POSIXct("2008-08-01"),as.POSIXct("2008-09-01"),
length=10))
testdfr$yvar <- rnorm(10)
sp <- interpSpline(yvar ~ Date, testdfr)
preddfr <- data.frame(Date=as.POSIXct("2008-08-02"))
predict(sp, preddfr)
thanks,
Remko
-------------------------------------------------
Remko Duursma
Post-Doctoral Fellow
Centre for Plant and Food Science
University of Western Sydney
Hawkesbury Campus
Richmond NSW 2753
Dept of Biological Science
Macquarie University
North Ryde NSW 2109
Australia
Mobile: +61 (0)422 096908
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.