[R] find end of monotonic part of vector

PIKAL Petr petr@p|k@| @end|ng |rom prechez@@cz
Fri Aug 7 14:05:16 CEST 2020


Hallo all

I have such data
> dput(kalo.v)
structure(list(cas = structure(c(1595847000, 1595847060, 1595847120, 
1595847180, 1595847240, 1595847300, 1595847360, 1595847420, 1595847480, 
1595847540, 1595847600, 1595847660, 1595847720, 1595847780, 1595847840, 
1595847900, 1595847960, 1595848020, 1595848080, 1595848140, 1595848200, 
1595848260, 1595848320, 1595848380, 1595848440, 1595848500, 1595848560, 
1595848620, 1595848680, 1595848740, 1595848800, 1595848860, 1595848920, 
1595848980, 1595849040, 1595849100, 1595849160, 1595849220, 1595849280, 
1595849340, 1595849400, 1595849460, 1595849520, 1595849580, 1595849640
), class = c("POSIXct", "POSIXt"), tzone = "UTC"), vodiv = c(999.9000244, 
999.9000244, 999.9000244, 999.9000244, 999.9000244, 999.9000244, 
999.9000244, 999.9000244, 999.9000244, 999.9000244, 999.9000244, 
999.9000244, 991.6404419, 925.2166748, 864.3446045, 812.1702271, 
758.9353027, 722.5073242, 684.5323486, 652.5300293, 82.18816376, 
141.1757813, 402.7521667, 999.9000244, 959.1779175, 967.0949707, 
517.1983643, 50, 50, 524.569458, 999.9000244, 999.9000244, 999.9000244, 
999.9000244, 999.9000244, 999.9000244, 999.9000244, 977.0491943, 
889.9714355, 999.9000244, 999.9000244, 999.9000244, 999.9000244, 
999.9000244, 999.9000244)), row.names = 71211:71255, class = "data.frame")

and I would like to automatically find endpoint of gradually decreasing part
(here point 20, vodiv = 652.****).

Usually I use diff but this is just a chunk of bigger data and diff seems to
be difficult to use. I appreciate any hint.

Best regards.
Petr


More information about the R-help mailing list