[Bioc-devel] runmean and NAs
Hi Florian, It has been on my TODO and II've just started working on this.
On 07/10/2012 02:19 AM, Hahne, Florian wrote:
Hi all, I was asking a while ago whether it would be possible for the runmean function to deal with NA values. Is that still on somebody's radar? Something similar to na.rm would be great. Haven't checked the source code for Rle_runsum yet, but ignoring Nas seems to be a straightforward thing to do. Currently I get
runmean(Rle(c(1:100, NA)), 10)
Error in .Call2("Rle_runsum", x, as.integer(k), PACKAGE = "IRanges") :
some values are NA
On a related note, why is this not working?
runmean(Rle(c(1:100, Inf)), 10)
Error in .Call2("Rle_runsum", x, as.integer(k), PACKAGE = "IRanges")
some values are NA, NaN, +/-Inf
Shouldn't that simply return Inf for the respective vector elements?
Currently no. The Inf creates a numeric Rle
> Rle(c(1:100, Inf))
'numeric' Rle of length 101 with 101 runs
Lengths: 1 1 1 1 1 1 1 1 ... 1 1 1 1 1
1 1 1
Values : 1 2 3 4 5 6 7 8 ... 94 95 96 97 98 99
100 Inf
so the code executed is Rle_real_runsum which has this check,
// calculate stat
if (i == 0) {
if (!R_FINITE(*curr_value))
error("some values are NA, NaN, +/-Inf");
While I am in there I will address this Inf issue too.
Valerie
Thanks, Florian
_______________________________________________ Bioc-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel