Sliding window analysis

Share:

Description

Applies a function within a sliding window of a numeric vector. Both the step size and the window size can be set by the user.

Usage

1

Arguments

FUN

a function to be applied within each window.

data

a numerical vector.

window

an integer setting the size of the window.

step

an integer setting the size of step between windows.

Details

Returns a vector of numeric values representing the applying the selected function within each window. The length will be unequal to the original data and will be determined primarily by the step size.

Author(s)

Heath Blackmon

References

http://coleoguy.github.io/

Examples

1
2
data <- c(1,2,1,2,10,2,1,2,1,2,3,4,5,6,2,5)
SlidingWindow("mean", data, 3, 1)