smooth: Smooth a variable

Description Usage Arguments Value See Also Examples

View source: R/smooth.R

Description

Smooth a variable in a cast using a weighted moving average.

Usage

1
smooth(x, k = 1, n = 1)

Arguments

x

vector of the variable of interest. It must have been recorded at approximately regular intervals (see slide() as to why).

k

order of the window; the window size is 2k+1.

n

number of times to smooth the data.

Value

A vector containing the smoothed variable, containing as many elements as the original variable.

See Also

slide() for the underlying implementation.

Examples

1
2
3
4
plot(-depth ~ chla, data=d)
lines(-depth ~ smooth(chla), data=d, type="l", col="red")
lines(-depth ~ smooth(chla, k=2, n=5), data=d, type="l", col="blue")
legend(1, 0, legend=c("k=1, n=1", "k=2, n=5"), col=c("red", "blue"), lty="solid")

jiho/castr documentation built on April 5, 2020, 2:12 p.m.