Skip to content

Behavior of na.rm = T in roll_median #26

@joranE

Description

@joranE

I'm confused by what na.rm = TRUE is supposed to do in roll_median:

library(RcppRoll)
x <- 1:20
x[3:4] <- NA
x

roll_medianr(x = x,n = 5,na.rm = TRUE)
[1] NA NA NA NA  2  2 NA NA  7  8  9 10 11 12 13 14 15 16 17 18
roll_maxr(x = x,n = 5,na.rm = TRUE)
[1] NA NA NA NA  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20

Why is the median in position 6 equal to 2 rather than 3.5? Why are there NAs positions 7 and 8?

Am I missing something obvious or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions