Learn R Programming

rioja (version 0.9-6)

interp.dataset: Interpolate a dataset

Description

Given a data frame of variables measured along a temporal or spatial gradient, interpolate each variable to new values of the gradient. Useful for interpolating sediment core data to the depths ot ages of another sequences, or to evenly spaced intervals.

Usage

interp.dataset(y, x, xout, method=c("linear","loess","sspline", "aspline"), 
     rep.negt=TRUE, span=0.25, df=min(20, nrow(y)*.7), ...)

Arguments

y
data frame to be interpolated.
x
numeric vector giving ages, depths (ie. x-values( for data frame to be interpolated.
xout
numeric vector of values to interpolate to.
method
interpolation method, should be an unambiguous abbreviation of either linear, loess, sspline or aspline. See details.
rep.negt
logical to indicate whether or not to replace negative values with zero in the interpolated data.
span
span for loess, default=0.25.
df
degress of freedome for smoothing spline, default is the lower of 20 or 0.7 * number of samples.
...
additional arguments to loess, smooth.spline and aspline.

Value

  • Function interp.datasets returns a data frame of the input data interpolated to the values given in xout. Values of xout outside the range of the oiriginal data are replaced by NA.

Details

Function interp.dataset interpolates the columns of data frame with rows measured at intervals given by x, to new intervals given by xout. This function is useful to interpolation one set of sediment core data to the depth or ages of another, or to a regular set of intervals. Interpolation can be done using linear interpolation between data points in the original series (default) using approx, using a fitted loess locally weighted regression, by smooth.spline or by aspline in the package akima. The latter three methods will also smooth the data and additional arguments may be passed to these functions to control the amount of smoothing. The effects of the interpolation can be visualised against the original sequence using strat.plot.simple.

See Also

approx, loess, smooth.spline, aspline for details of interpolation methods, and strat.plot.simple to visualise the effect of interpolation and / or smoothing.

Examples

Run this code
data(RLGH)
spec <- RLGH$spec
depth <- RLGH$depths$Depth

# interpolate new dataset to every 0.5 cm
# using default method (linear)
x.new <- seq(0, 20, by=0.5)
sp.interp <- interp.dataset(y=spec, x=depth, xout=x.new)
# examine the results and compare to original data 
strat.plot.simple(spec, depth, sp.interp, x.new)

Run the code above in your browser using DataLab