Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-Forge #1319] na.locf maxgap does not behave properly at tail of xts object #22

Closed
joshuaulrich opened this issue Feb 26, 2015 · 0 comments
Labels

Comments

@joshuaulrich
Copy link
Owner

Submitted by: Koert Kuipers
Assigned to: Nobody
R-Forge link

xts version 0.8-0 on R 2.12.0

library(xts)
Loading required package: zoo
Warning message:
package 'xts' was built under R version 2.12.2
x <- xts(c(1, 2, NA, NA, 5, 6, NA, NA), Sys.Date() + 1 : 8)
na.locf(x, maxgap = 1)
[,1]
2011-03-09 1
2011-03-10 2
2011-03-11 NA
2011-03-12 NA
2011-03-13 5
2011-03-14 6
2011-03-15 6
2011-03-16 6
na.locf(as.zoo(x), maxgap = 1)
2011-03-09 2011-03-10 2011-03-11 2011-03-12 2011-03-13 2011-03-14
1 2 NA NA 5 6
na.locf(as.zoo(x), na.rm = FALSE, maxgap = 1)

2011-03-09 1
2011-03-10 2
2011-03-11 NA
2011-03-12 NA
2011-03-13 5
2011-03-14 6
2011-03-15 NA
2011-03-16 NA

na.locf.xts should not replace the two two trailing NAs.
na.locf.zoo has unexpected behavior as well: it removes the trailing NAs, while the documentation says it will only remove leading NAs....

Best, Koert

Followups:

Date: 2011-03-08 17:47
Sender: Jeff Ryan
Patched as of rev 575 (xts 0.8-0.1)

x <- xts(c(1, 2, NA, NA, 5, 6, NA, NA), Sys.Date() + 1 : 8)
na.locf(x)
[,1]
2011-03-09 1
2011-03-10 2
2011-03-11 2
2011-03-12 2
2011-03-13 5
2011-03-14 6
2011-03-15 6
2011-03-16 6
na.locf(x, maxgap=1)
[,1]
2011-03-09 1
2011-03-10 2
2011-03-11 NA
2011-03-12 NA
2011-03-13 5
2011-03-14 6
2011-03-15 NA
2011-03-16 NA

Jeff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant