SlidingWindow: Sliding window analysis

View source: R/SlidingWindow.R

SlidingWindowR Documentation

Sliding window analysis

Description

Applies a function within a sliding window of a numeric vector or matrix. Both the step size and the window size can be set by the user. For the matrix impelentation the step size and window size is constrained to be the same in both the X and Y dimensions.

Usage

SlidingWindow(FUN, data, window, step, strict)

Arguments

FUN

a function to be applied within each window.

data

a numerical vector or matrix

window

an integer setting the size of the window

step

an integer setting the size of step between windows

strict

TRUE or FALSE indicating whether validation testing should be performed

Details

If the input data is a vector then returns a vector of numeric values representing the application of the selected function within each window. If the input data is a matrix then returns a matrix of numeric values representing the application fo the selected function within each window.

Author(s)

Heath Blackmon

References

http://coleoguy.github.io/

Examples

# vector example
x1 <- rnorm(100, sd=3)
z1 <- SlidingWindow(FUN="mean", data=x1, window=10, step=5, strict=TRUE)

# matrix example
x2 <- matrix(rnorm(10000),100,100)
z2 <- SlidingWindow(FUN="mean", data=x2, window=10, step=5, strict=TRUE)


coleoguy/evobir documentation built on May 8, 2024, 6:57 p.m.