Closed sklesse closed 3 years ago
Excellent. I figured the indexing was off but didn't take the time to try to wrap my head around it. It takes awhile to get into that proper head space for loops like that. I'd like to keep as.int
. It's a helper function (look in helpers.R we use throughout dplR for checks and tests.
I didn't think about that. I just copied the new code of chron.stablized
to bugfix instead of the whole package. Makes sense, that the helper functions wouldn't work outside of that.
It does makes testing outside of the project more complicated. But worth it in the long run.
I apologize for the botched code that I posted earlier. I must have cmd-z'ed a bit too much before copying my code in here.
The if-clause to check if winLength is odd or even was wrong. WL%%2 ==1 asks for the modulo (the rest of the division) to be one, i.e. WL to be odd, it should have been !=0 or ==1, and not !=1 as in the code I uploaded. Also, the "else" part had an error, effectively using WL+1 (i+winLength as opposed to i+winLength-1) to calculate rbar.
It should produce the correct amount of NAs to be padded now in both odd/even cases.
I spell-checked your warnings.
also: the
is.int
in the begininng is not a base function. How about askingif(winLength!=round(winLength))
instead?