apply.breaks:
Apply a function to regions of a signal
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
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.
Value
A vector containing the function results for each non-empty segment.
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).