.BG
.VE $Header: /usr3/s/current/s/.help/RCS/approx,v 1.2 83/12/30 19:24:11 rab Exp $
.FN approx
.TL
approx: Approximate Function from Discrete Values
.CS
approx(x, y, xout, method, n, rule)
.PP
.AG x,y
pairs of points giving (x,f(x)).  Can be a time-series or a
structure containing components named `x' and `y'.
.AG xout
optional set of x values for which function values are
desired.  If `xout' is not specified, the function will be
approximated at `n' equally spaced data points, spanning the range of `x'.
.AG method
character describing the method to be used in approximating
the function.  Possible values are "linear" for linear
interpolation (later may have "spline", etc).
.AG n
optional integer giving the number of points evenly spaced
between the minimum and maximum values in `x' to be used in
forming `xout'.  Default 50.
.AG rule
integer describing the rule to be used for values of `xout'
that are outside the range of `x'.  If `rule' is 1 (the
default), NAs will be supplied for any such points.  If
`rule' is 2, the `y' values corresponding to the extreme `x'
values will be used.
.RT
structure with components named `x' and `y'.
.EX
z <- approx(x,y,newx)   # linear interpolation at newx
quants <- approx(ppoints(x),sort(x),c(.1,.25,.5,.75,.9))$y
   # get the 10, 25, 50, 75 and 90 percentiles of x
.KW basic*
.KW interpolation
.KW dplot*
.KW math
.WR
