box_smooth | R Documentation |
Smooth data in vector x to its endpoint.
box_smooth(x, box_width = 28)
x |
1D data to be smoothed. |
box_width |
Width (in units of vector steps) of the box used for smoothing. |
Employ an endpoint box filter (aka "running mean" or endpoint smoother) to the 1-D data in x:
x_smoothed[i] = mean(x[i-box_width:i])
Where x is considered to be zero-padded vor values of i-box_width < 1.
x_smooth Smoothened version of x.
# Create a sine wave with noise
x = seq(0, 4*pi, 0.1)
y = sin(x) + runif(length(x))
# Apply endpoint smoothing
y_smooth = box_smooth(y, box_width = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.