[R] Spline Question

Berend Hasselman bhh at xs4all.nl
Wed Feb 15 09:42:26 CET 2012


On 14-02-2012, at 22:14, Hasan Diwan wrote:

>> dput(sensor.sample)
> structure(c(1328565718.65, 1328566608.9, 1328566162.65, 1328566571.1,
> 1328566598.85, 1328565634.3, 1328566513.95, 1328565123.65, 1328565827.1,
> ......
> What I'd like to do is get a spline through all the points. I'm
> thinking the spline function is my best approach. But a plot of the
> spline and the points shows it does not cross every one perfectly. Do
> I need to specify a particular method for this, or am I using the
> wrong approach? Thanks in advance! -- H

I assigned your str to the variable z.

And then did this

z.s <- spline(z[,1],z[,2]) 

z.range <- 1:50
plot(z.s$x[z.range],z.s$y[z.range])
lines(z.s$x[z.range],z.s$y[z.range], col=2)

z.range <- 401:450
plot(z.s$x[z.range],z.s$y[z.range])
lines(z.s$x[z.range],z.s$y[z.range], col=2)

And got the distinct impression that the spline is going through your points.

So what have you done and what made you draw your conclusion?

Berend



More information about the R-help mailing list