Learn R Programming

TauP.R (version 1.5)

LinInterp: Linear Interpolation

Description

Linearly interpolates, allowing multiple y-values for a given x-value.

Usage

LinInterp(xin, yin, xout, mode = 'data')

Arguments

xin

Input x vector

yin

Input y vector

xout

x-values at which to interpolate

mode

How to handle x-values with multiple y-values: one of 'jump', 'data', 'all'

Value

Vector of interpolated y-values corresponding to xout.

Details

Regarding the 'mode' argument: 'data' interpolates using the mean of all y-values for the given x-value, while 'jump' or 'all' uses only the y-value on the same side of the discontinuity as the element of 'xout'.

Examples

Run this code
# NOT RUN {
xin = c(1, 2, 3, 3, 4, 5)
yin = c(0, 0, 0, 1, 1, 1)
xout = 3.5

LinInterp(xin, yin, xout, 'all')
LinInterp(xin, yin, xout, 'data')

# }

Run the code above in your browser using DataLab