

   IInntteerrppoollaattiinngg SSpplliinneess

        splinefun(x, y, method = "fmm")
        spline(x, y, n = 3*length(x), method = "fmm",
               xmin = min(x), xmax = max(x))

   AArrgguummeennttss::

        x,y: vectors giving the coordinates of the points to be
             interpolated.  Alternatively a single plotting
             structure can be specified.

     method: specifies the type of spline to be used.  Possible
             values are `"fmm"', `"natural"' and `"periodic"'.

          n: interpolation takes place at `n' equally spaced
             points spanning the interval [`xmin', `xmax'].

       xmin: left-hand endpoint of the interpolation interval.

       xmax: right-hand endpoint of the interpolation interval.

   DDeessccrriippttiioonn::

        `spline' performs cubic spline interpolation of the
        given data points.  It returns a list containing compo-
        nents `x' and `y' which give the ordinates where inter-
        polation took place and the interpolated values.

        `splinefun' returns a function which will perform cubic
        spline interpolation of the given data points.  This is
        often more useful than `spline'.

        If `method="fmm"', the spline used is that of Forsythe,
        Malcolm and Moler (an exact cubic is fitted through the
        four points at each end of the data, and this is used
        to determine the end conditions).  Natural splines are
        used when `method="natural"', and periodic splines when
        `method="periodic"'.

   RReeffeerreenncceess::

        Forsythe, G. E., M. A. Malcolm and C. B. Moler (1977).
        Computer Methods for Mathematical Computations.

   SSeeee AAllssoo::

        `approx' and `approxfun' for constant and linear inter-
        polation.

   EExxaammpplleess::

        x <- 1:10
        y <- rnorm(10)
        op <- par(mfrow = c(2,1), mgp = c(2,.8,0), mar = .1+c(3,3,3,1))
        plot(x, y, main = "spline[fun](.) through 10 points")
        lines(spline(x, y))
        lines(spline(x, y, n = 201), col = 2)

        f <- splinefun(x, y)
        ls(envir = environment(f))
        splinecoef <- eval(expression(z), envir = environment(f))
        curve(f(x), 1, 10, col = "green", lwd = 1.5)
        points(splinecoef, col = "purple", cex = 2)
        par(op)

