0

Possible Duplicate:
calculate peak values in a plot using R

I have a table with two columns(ppm and freq). The data is from nmr spectroscopy. I plotted the graph with the data. I got a spectra image from it.

I need to find the peak values from the spectra which is above certain value in y axis. My data looks like this. It has ppm value from 11 to -1.

I need to find the peaks with y value at least of 5.Any help me out of this.Values starting with zero belong to freq column.

.data <- structure(list(ppm = c(11.3633, 11.3629, 11.3625, 11.3621, 11.3617, 
  11.3613, 11.361, 11.3606, 11.3602, 11.3598, 11.3594, 11.359, 
  11.3586, 11.3582, 11.3578, 11.3574, 11.357, 11.3566, 11.3562, 
  11.3558, 11.3554, 11.355, 11.3546, 11.3542, 11.3538, 11.3534, 
  11.353, 11.3526, 11.3522, 11.3518, 11.3514, 11.351, 11.3506, 
  11.3502, 11.3499, 11.3495, 11.3491, 11.3487, 11.3483, 11.3479, 
  11.3475, 11.3471, 11.3467), freq = c(0.00498359, 0.00511016, 
  0.00557969, 0.00732578, 0.00936094, 0.00874531, 0.00472031, 0.00185781, 
  0.00498438, 0.0115414, 0.0142, 0.0108344, 0.00561406, 0.000523438, 
  -0.00586406, -0.0102078, -0.00525078, 0.0073375, 0.0149227, 0.0105781, 
  0.00294766, 0.00271172, 0.00764531, 0.00919609, 0.00638828, 0.00396953, 
  0.00251797, -0.000163281, -0.00205703, 4.53125e-05, 0.00394922, 
  0.00587578, 0.0070375, 0.00937109, 0.00945234, 0.00447656, -0.000355469, 
  0.000999219, 0.00497031, 0.00409922, -0.000359375, -0.00106484, 
  0.00263672)), .Names = c("ppm", "freq"), class = "data.frame", row.names = c(NA, 
  -43L))
Community
  • 1
  • 1
sathya
  • 177
  • 1
  • 2
  • 7
  • [see also](http://stackoverflow.com/a/9081529/471093) and another question by that guy – baptiste Jun 06 '12 at 06:32
  • I used peak function to find the peaks in plot.Even then i cant find the peaks with higher frequency value.The peak function is predicting even very small peaks in the plot.The peak function i used is peaks<-function(series,span=3){ z <- embed(series, span) s <- span%/%2 v<- max.col(z) == 1 + s result <- c(rep(FALSE,s),v) result <- result[1:(length(result)-s)] result } plot(ppm,freq, type="l") p <- which(peaks(freq, span=3)) points(ppm[p], freq[p], col="red") – sathya Jun 06 '12 at 06:33

0 Answers0