You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
but what I get is my original xts_with_data.
(it works as expected with na.approx() )
AkselA suggested (on stackoverflow) that ... "It seems like the source of your troubles is a missing feature in xts:::na.locf.xts. It might be worth letting Joshua (the developer) know, if he doesn't already."
AkselA also pointed me to a couple of workaround:
xts_all<- merge(xts_with_data, xts_with_timestamps)[,-2]
na.locf(xts_all)[index(xts_with_timestamps)]
# or
na.locf.default(xts_with_data, xout=index(xts_with_timestamps))
# or
na.locf(zoo(xts_with_data), xout=index(xts_with_timestamps))
We were converting all xts objects to a common type when merging, and
we included the types of zero-width xts objects in our check. This is
a problem because zero-width objects created via the xts constructor
are numeric by default. So calling merge.xts() on any non-numeric xts
objects and a zero-width xts object returned a numeric result.
This manifested in the na.locf() test where xout is specified, because
na.approx.zoo() is called at one point. And that method does a merge
of the original object with an zero-width zoo object created via
zoo(,idx).
See #215.
Description
It seems xout is not working with na.locf()
Expected behavior
That xout defines the timestamps of the output (as with na.approx() )
Minimal, reproducible example
I have two xts time series data sets. One with my data and another with time stamps that I would like to use.
I would expect output like this
but what I get is my original xts_with_data.
(it works as expected with na.approx() )
AkselA suggested (on stackoverflow) that ... "It seems like the source of your troubles is a missing feature in xts:::na.locf.xts. It might be worth letting Joshua (the developer) know, if he doesn't already."
AkselA also pointed me to a couple of workaround:
(stackoverflow: https://stackoverflow.com/questions/47219803/last-observation-carried-forward-locf-on-xts-in-r-not-like-na-approx)
The text was updated successfully, but these errors were encountered: