nwin: Calculate number of windows in a time-series with a given...

View source: R/generic_utilities.R

nwinR Documentation

Calculate number of windows in a time-series with a given duration

Description

Calculate number of windows in a time-series with a given duration

Usage

nwin(x, WIN, INC, flex = FALSE, SR = frequency(x), return = c("number", "all"))

Arguments

x

either the duration in seconds of a time-series, or a rats or ts object

flex

if true the first and last windows are stretched so to have exactly length(x)/inc resulting windows

SR

the number of samples per second (i.e. frequency)

return

either "number", which returns the number of windows, or "all" which returns a data.frame with the start and end of each window.

winSec

the width of each window, in seconds

incSec

the amount of increment between each window (incSec == winSec gives non-overlapping windows)

Examples

\._./\.^.-^\._./\.^.-^\._./\.^.-^\._./\.^.-^
|---------------o---------------|
    |---------------o---------------|
        |---------------o---------------|
            |---------------o---------------|
            
Here you need to have at least half window before getting reliable values
Instead with flex:
\._./\.^.-^\._./\.^.-^\._./\.^.-^\._./\.^.-^
o---------------|                  <---FLEX WINDOW 1
|---o---------------|              <---FLEX WINDOW 2
|-------o---------------|          <---FLEX WINDOW 3
|-----------o---------------|      <---FLEX WINDOW 4

|---------------o---------------|  <---FIRST COMPLETE WINDOW
    |---------------o---------------|
        |---------------o---------------|
            |---------------o---------------|


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