smoother: Smooth a plot of metabolism data

View source: R/smoother.R

smootherR Documentation

Smooth a plot of metabolism data

Description

Smooth a plot of metabolism data using a moving window average

Usage

smoother(x, ...)

## Default S3 method:
smoother(x, window = 5, sides = 2, ...)

Arguments

x

input object

...

additional arguments passed to filter

window

numeric vector defining size of the smoothing window, passed to filter

sides

numeric vector defining method of averaging, passed to filter

Details

This function uses a moving window average to smooth metabolism data for plotting. It has nothing to do with weighted regression (wtreg) and is meant only for plotting aesthetics. The function is a simple wrapper to filter. The window argument specifies the number of observations included in the moving average. The sides argument specifies how the average is calculated for each observation (see the documentation for filter). A value of 1 will filter observations within the window that are previous to the current observation, whereas a value of 2 will filter all observations within the window centered at zero lag from the current observation.

Value

Returns a data.frame of the smoothed metabolism data.

See Also

filter

Examples

## Not run: 
data(SAPDC)

# metadata for the location
tz <- 'America/Jamaica'
lat <- 31.39
long <- -81.28

# estimate ecosystem metabolism using observed DO time series
metab <- ecometab(SAPDC, DO_var = 'DO_obs', tz = tz,
 lat = lat, long = long)

# smooth metabolism data with 20 day moving window average
tosmooth <- metab[, c('Pg', 'Rt', 'NEM')]
smoother(tosmooth, window = 20)

## End(Not run)

fawda123/WtRegDO documentation built on March 18, 2024, 9:04 p.m.