View source: R/SlidingWindow.R
SlidingWindow | R Documentation |
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.
SlidingWindow(FUN, data, window, step, strict)
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 |
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.
Heath Blackmon
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.