calculate peak values in a plot using R -
i have table 2 variables.the data nmr.so when plot spectrum.i found peaks in plot.but need know how list values of peak , store them variable.anyone please help.
an easy implementation based on brian ripley's post @ r-help:
peaks <- function(x, halfwindowsize) { windowsize <- halfwindowsize * 2 + 1 windows <- embed(x, windowsize) localmaxima <- max.col(windows, "first") == halfwindowsize + 1 return(c(rep(false, halfwindowsize), localmaxima, rep(false, halfwindowsize))) } example:
x <- c(1,3,1,3,1) peaks(x, 1) ## [1] false true false true false
Comments
Post a Comment