OpenDendro / dplR

This is the dev site for the dplR package in R
38 stars 14 forks source link

Update chron.stabilized.R #5

Closed sklesse closed 4 years ago

sklesse commented 4 years ago

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 asking if(winLength!=round(winLength)) instead?

AndyBunn commented 4 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.

sklesse commented 4 years ago

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.

AndyBunn commented 4 years ago

It does makes testing outside of the project more complicated. But worth it in the long run.