Unexpected behavior when extracting minima using turnpoints (Pastecs
package in R)
So I have some data, height.
> print(height)
V3 V4 V5 V6 V7
V8 V9 V10 V11 V12
V13 V14 V15
0.0000000 -3.1486232 39.1502937 -2.8437808 -24.7633269
-35.4022061 -36.2401943 46.4133021 -19.1868097 0.4067331
22.6768200 -38.8550971 -41.3161054
V16 V17 V18 V19 V20
33.0446273 41.4934899 19.9558741 3.3477473 0.3611974
I then apply turnpoints(), and use extract() to get what looks like a
logical vector indicating the positions of the minima.
tp = turnpoints(height)
pitpositions = extract(tp, peak = FALSE, pit = TRUE)
print(pitpositions) # [1] 0 1 0 0 0 0 1 0 1 0 0 0 1 0 0 0 0 0
I would expect that height[pitpositions] would give the values of the
minima, and that height[!pitpositions] would give the values of the
non-minima.
The latter works as expected:
> height[!pitpositions]
V3 V5 V6 V7 V8
V10 V12 V13 V14 V16
V17 V18 V19
0.0000000 39.1502937 -2.8437808 -24.7633269 -35.4022061
46.4133021 0.4067331 22.6768200 -38.8550971 33.0446273
41.4934899 19.9558741 3.3477473
V20
0.3611974
But the former doesn't, and I don't know how to interpret the results:
> height[pitpositions]
V3 V3 V3 V3
0 0 0 0
So my questions are:
Why is this happening?
How can I get the result that I'm looking for (basically the opposite of
height[!pitpositions]?
Thanks!
--Davis
Edit:
To answer question number 2, I can get what I'm looking for using
height[tp$pits]. tp$pits seems to have the same information as
pitpositions, but when I print out pitpositoins I get a series of TRUE
FALSE, whereas when I print out tp$pits I get a series of 0 1. I would
have thought these were equivalent, as 0 == FALSE and 1 == TRUE.
No comments:
Post a Comment