[R] finding peaks in a simple dataset with R
    Dylan Beaudette 
    dylan.beaudette at gmail.com
       
    Wed Nov 23 23:47:17 CET 2005
    
    
  
On Wednesday 23 November 2005 10:15 am, Tuszynski, Jaroslaw W. wrote:
> >> I am looking for some way to locate peaks in a simple x,y data set.
>
> See my 'msc.peaks.find' function in 'caMassClass', it has a simple peak
> finding algorithm.
>
> Jarek Tuszynski
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
Jarek,
Thanks for the tip. I was able to install the caMassClass package and all of 
its dependancies. In addition, I was able to run the examples on the manual 
pages.
However, The format of the input data to the 'msc.peaks.find' function is not 
apparent to me. In its simplest form, my data looks something like this:
2.00 233
2.04 220
...
11.60 540
12.00 600   <-- a peak!
12.04 450
...
Here is an example R session, trying out the function you suggested:
#importing my data like this:
X <- read.table("input.dat", header=TRUE)
#from the example:
Peaks = msc.peaks.find(X)
#errors with:
Error in sort(x, partial = unique(c(lo, hi))) :
        'x' must be atomic
Also: I have tried one of the functions ( 'getPeaks' ) listed on the 
'msc.peaks.find' manual page, however I am still having a problem with the 
format of my data vs. what the function is expecting.
#importing my data like this:
X <- read.table("input.dat", header=TRUE)
#setup an output file for peak information
peakfile <- paste("peakinfo.csv", sep="/")
#run the analysis:
getPeaks(X,peakfile)
#errors with:
Error in area/max(area) : non-numeric argument to binary operator
In addition: Warning message:
no finite arguments to max; returning -Inf
any ideas would be greatly appreciated!
-- 
Dylan Beaudette
Soils and Biogeochemistry Graduate Group
University of California at Davis
530.754.7341
    
    
More information about the R-help
mailing list