localmax: calculate a local maximum

Description Usage Arguments Details Value Author(s) References Examples

View source: R/localmax.R

Description

The function calculates a local maximum of the vector x surrounded by at least n.points lower numbers.

Usage

1
localmax(x, n.points=2)

Arguments

x

a vector of numbers.

n.points

a minimum number of lower values to determine the local maximum. Default is two points.

Details

The function calculates a local maximum of the vector x, i.e. the highest value of the vector x surrounded by at least n lower numbers. The concept of the local maximum applied to ERP analysis is taken from Luck (2005).

Value

The local maximum of the vector x is returned.

Author(s)

Giorgio Arcara

References

Luck, S., J. (2005). An Introduction to the Event-Related Potential Technique. Cambridge, Mass.: The MIT Press.

Examples

1
2
3
4
5
6
7
8
x=seq(-5.5,1,0.001)

y=sin(x)+0.3*x

plot(x,y, type="l")

#print an horizontal line intersecting the local maximum
abline(h=localmax(y)) 

erpR documentation built on May 21, 2017, 4:06 a.m.

Search within the erpR package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.