Michael S.
2011-May-25 09:08 UTC
[R] approximate function and find local peaks (Maxima or Minima)
Hi, I have a data-matrix:> CBZeit Low 2 2011-05-02 08:05:05 7596.0 3 2011-05-02 08:10:06 7593.5 4 2011-05-02 08:15:11 7594.5 5 2011-05-02 08:20:15 7597.5 6 2011-05-02 08:25:18 7595.0 7 2011-05-02 08:30:20 7593.5 8 2011-05-02 08:35:21 7593.0 9 2011-05-02 08:40:21 7593.0 10 2011-05-02 08:45:25 7599.0 11 2011-05-02 08:50:34 7596.0 12 2011-05-02 08:55:59 7591.0 13 2011-05-02 09:01:00 7590.5 14 2011-05-02 09:06:00 7590.5 15 2011-05-02 09:11:04 7590.5 16 2011-05-02 09:16:04 7591.0 17 2011-05-02 09:21:06 7593.0 18 2011-05-02 09:26:08 7596.0 19 2011-05-02 09:31:09 7596.0 20 2011-05-02 09:36:10 7599.0 21 2011-05-02 09:41:11 7601.5 22 2011-05-02 09:46:11 7608.0 23 2011-05-02 09:51:18 7611.5 24 2011-05-02 09:56:20 7605.5 25 2011-05-02 10:01:20 7601.5 I want to approximate this data (actually I dont care, whether keep the time information, or lose it, while making it a function) With approxfun( ), it seems, like I managed to apprximate a function. f <- approxfun(2:nrow(CB), CB[2:nrow(CB),2]) But how do I defferentiate f()? g<-deriv(f(2:nrow(CB)),"x") Did not work out for me, or at least, I dont know how to get those "x", with g(x)=0. My ultimate goal, is to find all the local minima of CB[,2]. (min() gives only the global minimum) Any suggestions how to do it? Thanks for your help in advance. Michael -- [[alternative HTML version deleted]]