winScan: Apply several functions in a sliding window

Description Usage Arguments Details Value Examples

Description

winScan() applies a list of functions to each of a list of variables, using a sliding window approach. This can be a "rolling" window or a "position" window (see details). If required, the windows can be defined independently for one or more grouping variables.

.winSlider() is an internal function called by winScan(). It creates sliding window coordinates and applies a list of functions to each window.

.winStats() is an internal function called by mclapply() in .winSlide().

Usage

1
2
3
4
5
6
7
8
9
winScan(x, ...)

## S4 method for signature 'data.frame'
winScan(x, groups = NULL, position = NULL, values,
  win_size, win_step = 0.5 * win_size, funs = "mean", cores = 1)

.winSlider(x, values, win_size, win_step, funs, cores)

.winStats(win_start, win_size, funs, values, x)

Arguments

x

a data.frame object on which to calculate window statistics.

...

other arguments passed to specific methods.

groups

vector with the name of variables on which to group the data.frame. It can be set to NULL, if there are no groups. Default: NULL

position

name of variable which contains the positions on which to calculate the windows. If set to NULL, a "rolling" window will be computed instead. Default: NULL

values

vector of variables on which to calculate statistics.

win_size

size of the window.

win_step

step of the window. Default: 0.5*win_size.

funs

vector of functions to compute for each window. Default: "mean".

cores

number of processing cores.

x

data.frame on which to calculate window statistics.

Details

A "rolling" window is based on consecutive rows in the data.frame. For example, if 'win_size = 10' and 'win_step = 5', then, on a data.frame with 100 rows there will be 20 windows, each containing 10 rows of the data.frame. A "position" window is based on a variable containing positions.

Value

a data.frame of window-computed statistics.

Examples

1
2
... to be filled in
... to be added

tavareshugo/windowscanr documentation built on May 31, 2019, 3:57 a.m.