apply.breaks: Apply a function to regions of a signal

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Applies a specified function to sections of an input signal in between specified index points. The indices can be supplied explicitly in the idx parameter, or as the logical vector btm in which the divider points are set to TRUE. By default, the link{median} of each segment is calculated.

Usage

1
apply.breaks(x, btm = NULL, f = median, idx = (1:length(btm))[btm])

Arguments

x

The data vector whose segments are to be processed.

btm

A logical vector containing TRUE at the points where the data in x should be split into segments. Either this or idx must be provided.

f

A function object to apply to each segment of data. Should return a single value. The default is to use the median function.

idx

A vector of indices at which the data vector should be split into segments. The data at the index is not included in the segment. Either this or btm must be provided.

Details

Unbounded stretches at each end are dropped, as are empty regions (i.e. regions between adjacent dividers). Thus, if there are N divider points there will be at most N-1 returned values (and possibly fewer).

Value

A vector containing the function results for each non-empty segment.

Author(s)

Matthew Caldwell

See Also

find.bottom

Examples

1
2
x <- rnorm(500)
apply.breaks(x, idx=50 * 1:10)

breakage documentation built on May 1, 2019, 11:30 p.m.