detect.events: splits a frequency contour into separate events based upon...

Description Usage Arguments Value Author(s) See Also Examples

View source: R/detect.events.R

Description

steps along a frequency contour and calculates the weighted distance between consecutive instants. if the weighted distance is > 1 then a new event begins

Usage

1
detect.events(X, var.weights)

Arguments

X

a data frame of frequency contour measurements

var.weights

the weights of the variables in X

Value

a factor of event ids, one for each instant

Author(s)

Benjamin N. Taft ben.taft@landmarkacoustics.com

See Also

make.peaks

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (X, var.weights) 
{
    events <- rep(1, nrow(X))
    for (j in 1:ncol(X)) X[, j] <- X[, j] * var.weights[j]
    for (i in 2:nrow(X)) {
        events[i] <- events[i - 1]
        delta <- sum((X[i, ] - X[i - 1, ])^2)
        if (delta > 1) 
            events[i] <- events[i] + 1
    }
    return(invisible(events))
  }

landmarkacoustics/SoundPoints-R documentation built on May 29, 2019, 9:14 a.m.