0

I'm using the R function interSpline to smooth out a curve of a line with 9 points (so that it doesn't look like it's just connecting the dots). Here is an example of what I'm doing:

plot(NA, NA, xlim = c(0,1), ylim = c(0,1), xlab = "p", ylab = "q")
lines(predict(interpSpline(data.x, data.fit)))
points(data.x, data.y, pch = 0)

However I can't find what methodology is actually being applied in the interSpline function.

  • 2
    Which packages does the function come from? Have you tried tying the function name into R and pressing enter (no parentheses)? If it's an S4 method, the digging is a bit harder. In that case, I find it easier to browse github or clone the code locally and explore it using e.g. Rstudio. – Roman Luštrik Feb 25 '19 at 18:42
  • If it's `splines`, then it's in base R (it was removed from CRAN some time ago). `splines:::interpSpline.default` could be helpful. To Roman's suggestion for github, I typically start with Winston Chang's https://github.com/wch/r-source mirror, then search for the function `interpSpline`, and on page 2 you'll find a reference to the function: https://github.com/wch/r-source/blob/5a156a0865362bb8381dcd69ac335f5174a4f60c/src/library/splines/R/splineClasses.R#L122 – r2evans Feb 25 '19 at 18:46
  • it's from the `splines` R package – Bernard Lowe Feb 25 '19 at 18:52
  • Thank you for the comments, but looking at the deeper code of the function isn't helping. I was wondering if there was any document of the function that explained the rationale behind it or something close to it. – Bernard Lowe Feb 25 '19 at 18:55

1 Answers1

0

Too long for a comment: As you do not provide a reproducible example, I just started with ??interSpline suggesting splines::interpSpline.

From the docs:

An object that inherits from (S3) class spline. The object can be in the B-spline representation, in which case it will be of class nbSpline for natural B-spline, or in the piecewise polynomial representation, in which case it will be of class npolySpline.

Thus, your question depends on the way you use it (it is class dependent). People could help further, if you provide a mminimal reproducible example.

(In general read (1) how do I ask a good question, (2) how to create a MCVE as well as (3) how to provide a minimal reproducible example in R.)

Christoph
  • 6,841
  • 4
  • 37
  • 89