Dear Mr. Tuszynski,

I would like to request what I believe would be a beneficial update / patch
to the runmean() function in the caTools package.

Consider the following

R>> x = 1:100
R>> is.integer(x)
[1] TRUE
R>> library(caTools)
R>> head(runmean(x, 5, alg="exact"))
[1] 8.487983e-314 1.060998e-313 1.273197e-313 1.697597e-313 2.121996e-313
2.546395e-313
R>> head(runmean(x, 5, alg="C"))
[1] 2.0 2.5 3.0 4.0 5.0 6.0
R>> head(runmean(as.double(x), 5, alg="C"))
[1] 2.0 2.5 3.0 4.0 5.0 6.0
R>> head(runmean(as.double(x), 5, alg="exact"))
[1] 2.0 2.5 3.0 4.0 5.0 6.0

As you can see (and can be verified in the code), unlike the call for the
"C" algorithm, the "exact" algorithm does not make sure that x is stored as
double resulting in occasional unexpected behavior.

## From caTools::runmean
if (alg == "exact") {
    .C("runmean_exact", x, y, as.integer(n), as.integer(k), NAOK = TRUE, DUP
= FALSE, PACKAGE = "caTools")
}
else if (alg == C"){
    .C("runmean", as.double(x), y, as.integer(n), as.integer(k), NAOK =
TRUE, DUP = FALSE, PACKAGE = "caTools")
}

Thanks once again for the fantastic package,

Michael Weylandt

cc: R-Help List.

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to