Last data update: 2014.03.03

R: Identify local maximum within a slide window.
localMaximumR Documentation

Identify local maximum within a slide window.

Description

Find local maximum by transform the vector as matrix, then get the the maximum of each column. This operation is performed twice with vecctor shifted half of the winSize.

Usage

localMaximum(x, winSize = 5)

Arguments

x

a vector represents a signal profile

winSize

the slide window size, 5 by default.

Details

Instead of find the local maximum by a slide window, which slide all possible positions, we find local maximum by transform the vector as matrix, then get the the maximum of each column. This operation is performed twice with vecctor shifted half of the winSize. The main purpose of this is to increase the efficiency of the algorithm.

Value

Return a vector with the same length of the input x. The position of local maximum is set as 1, 0 else where.

Author(s)

Pan Du

See Also

getLocalMaximumCWT

Examples

x <- rnorm(200)
lmax <- localMaximum(x, 5)
maxInd <- which(lmax > 0)
plot(x, type='l')
points(maxInd, x[maxInd], col='red')

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(MassSpecWavelet)
Loading required package: waveslim

waveslim: Wavelet Method for 1/2/3D Signals (version = 1.7.5)

> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/MassSpecWavelet/localMaximum.Rd_%03d_medium.png", width=480, height=480)
> ### Name: localMaximum
> ### Title: Identify local maximum within a slide window.
> ### Aliases: localMaximum
> ### Keywords: methods
> 
> ### ** Examples
> 
> x <- rnorm(200)
> lmax <- localMaximum(x, 5)
> maxInd <- which(lmax > 0)
> plot(x, type='l')
> points(maxInd, x[maxInd], col='red')
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>