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

na.locf.xts() wrong when only first row of multi-column object is not NA #232

Closed
joshuaulrich opened this Issue Apr 14, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@joshuaulrich
Owner

joshuaulrich commented Apr 14, 2018

Calling na.locf() on an xts object that is all NA except for the first row doesn't propagate the first row value to all subsequent rows. Coercing to zoo and running na.locf() works correctly and caries the values forward.

x <- .xts(matrix(NA_integer_, 5, 2), 1:5)
x[1,] <- 1:2
na.locf(x)
#                     [,1] [,2]
# 1969-12-31 18:00:01    1   NA
# 1969-12-31 18:00:02    1   NA
# 1969-12-31 18:00:03   NA   NA
# 1969-12-31 18:00:04   NA   NA
# 1969-12-31 18:00:05   NA   NA
na.locf(as.zoo(x))
#                        
# 1969-12-31 18:00:01 1 2
# 1969-12-31 18:00:02 1 2
# 1969-12-31 18:00:03 1 2
# 1969-12-31 18:00:04 1 2
# 1969-12-31 18:00:05 1 2

Thanks to Christopher Katsulis (via email) for the report and reproducible example!

@joshuaulrich joshuaulrich added the bug label Apr 14, 2018

@joshuaulrich joshuaulrich self-assigned this Apr 14, 2018

@ckatsulis

This comment has been minimized.

Show comment
Hide comment
@ckatsulis

ckatsulis Apr 17, 2018

In windows, I am currently getting the following error

Error in na.locf.xts(data) : 
  na.locf.xts only handles univariate, dimensioned data

ckatsulis commented Apr 17, 2018

In windows, I am currently getting the following error

Error in na.locf.xts(data) : 
  na.locf.xts only handles univariate, dimensioned data
@joshuaulrich

This comment has been minimized.

Show comment
Hide comment
@joshuaulrich

joshuaulrich May 6, 2018

Owner

In windows, I am currently getting the following error

Error in na.locf.xts(data) :
na.locf.xts only handles univariate, dimensioned data

Following up here, since this was resolved via private email. Here's my reply:

That's weird. It suggests you're not using the latest master from GitHub, because I don't see that error text in the code:

josh@thinkpad: /storage/git/R/xts (master)
> grep "only handles" -r *

josh@thinkpad: /storage/git/R/xts (master)

Can you double-check that you have the latest HEAD from master?

And I asked in a different email thread:

Did you get your Windows na.locf.xts "by-column" error sorted out?

and Chris replied

I believe yes.... deleted the folder and reinstalled from github

Owner

joshuaulrich commented May 6, 2018

In windows, I am currently getting the following error

Error in na.locf.xts(data) :
na.locf.xts only handles univariate, dimensioned data

Following up here, since this was resolved via private email. Here's my reply:

That's weird. It suggests you're not using the latest master from GitHub, because I don't see that error text in the code:

josh@thinkpad: /storage/git/R/xts (master)
> grep "only handles" -r *

josh@thinkpad: /storage/git/R/xts (master)

Can you double-check that you have the latest HEAD from master?

And I asked in a different email thread:

Did you get your Windows na.locf.xts "by-column" error sorted out?

and Chris replied

I believe yes.... deleted the folder and reinstalled from github

@joshuaulrich joshuaulrich added this to the Release 0.11-0 milestone Jul 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment