byWin: Applies a function over moving windows

View source: R/generic_utilities.R

byWinR Documentation

Applies a function over moving windows

Description

Applies a function over moving windows

Usage

byWin(
  x,
  WIN,
  INC,
  flex = TRUE,
  FUN,
  ...,
  position = c("mid", "first", "last"),
  cores = 1
)

wapply(
  x,
  WIN,
  INC,
  flex = TRUE,
  FUN,
  ...,
  position = c("mid", "first", "last"),
  cores = 1
)

Arguments

x

a rats object or another object for which as.rats methods are available

WIN

integer. the window size in the time unit of x (e.g. seconds)

INC

integer. the increment size in the time unit of x (e.g. seconds)

flex

logical. Creates additional shorter windows at the start and end of the signal to maximize the coverage of the original series

FUN

The function to be executed

...

Additional parameters to be passed to FUN

position

Should the time value of each calculation be positioned as the first, middle or last sample of each window?

cores

integer or logical. The number of cores to be used for parallelization. if set to 1 or FALSE, parallelization is turned off. If set to TRUE, cores are automatically selected. Please note that most simple tasks can be faster if run as single core due to the overhead of scheduling the task and returning the result can be greater than the time to execute the task itself, resulting in poor performance.

Value

a rats time series with a $x element pointing to the windowed position of $y elements


kleinbub/rIP documentation built on Dec. 21, 2024, 9:15 a.m.