Learn R Programming

PTXQC (version 1.0.4)

getMaxima: Find the local maxima in a vector of numbers.

Description

A vector of booleans is returned with the same length as input (omitting NA's) which contains TRUE when there is a maximum. Simply sum up the vector to get the number of maxima.

Usage

getMaxima(x, thresh_rel = 0.2)

Arguments

x

Vector of numbers

thresh_rel

Minimum relative intensity to maximum intensity of 'x' required to be a maximum (i.e., a noise threshold). Default is 20%.

Value

Vector of bool's, where TRUE indicates a local maximum.

Examples

Run this code
# NOT RUN {
    r = getMaxima(c(1,0,3,4,5,0))                                
    all(r == c(TRUE,FALSE,FALSE,FALSE,TRUE,FALSE))
    
# }

Run the code above in your browser using DataLab