Closed ethanbsmith closed 3 years ago
i think the problem is line 89 in runFun.r :
is.na(result) <- c(1:(n-1+NAs))
should be:
is.na(result) <- c(0:(n-1+NAs))
other runXXX functions seem to have the same issue
> identical(runMax(1, n = 1, cumulative = T), runMax(1, n = 1, cumulative = F))
[1] FALSE
> identical(runMin(1, n = 1, cumulative = T), runMin(1, n = 1, cumulative = F))
[1] FALSE
Note for future me: runCov
, runCor
, runVar
, runSD
always return NA for the first element when n = 1, cumulative = TRUE
, which is consistent with cov(t(1))
. Similarly, runMAD(1:2, n = 1, cumulative = TRUE)
is zero because mad(1)
is zero.
Description
mean of a single value should be the value itself, so the first value should not be NA when n = 1 may be related to #88
Expected behavior
when n = 1, first value should be itself
Minimal, reproducible example
Session Info