joshuaulrich / xts

Extensible time series class that provides uniform handling of many R time series classes by extending zoo.
http://joshuaulrich.github.io/xts/
GNU General Public License v2.0
220 stars 71 forks source link

fill_window_dups_rev not available for .Call() for package xts #276

Closed AndreMikulec closed 5 years ago

AndreMikulec commented 5 years ago

Description

Error in .Call("fill_window_dups_rev", tmp, .index(x), PACKAGE = "xts") : 
  "fill_window_dups_rev" not available for .Call() for package "xts"
Called from: 
Browse[1]> match.call()
window_idx(x = x, index. = i)

Expected behavior

'not an error'

Minimal, reproducible example and Session Info

So exactly

Sys.setenv(TZ="UTC")
library(xts)
xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
Error in .Call("fill_window_dups_rev", tmp, .index(x), PACKAGE = "xts") :
  "fill_window_dups_rev" not available for .Call() for package "xts"

I tried both CRAN xts and github lastest (master) xts. The error is the same.

devtools::session_info()
Session info ------------------------------------------------------------------
 setting  value
 version  R version 3.5.1 Patched (2018-09-11 r75286)
 xts                  * 0.11-1   2018-09-12 CRAN (R 3.5.1) 
devtools::session_info()
Session info ------------------------------------------------------------------
 setting  value
 version  R version 3.5.1 Patched (2018-09-11 r75286)
 xts                  * 0.11-2   2018-10-11 Github (joshuaulrich/xts@57b00a3)

Tried Patched R. https://cran.r-project.org/bin/windows/base/rpatched.html This is a combined Windows 32/64 bit binary build R including patches up to 2018-10-10 (r75424).

New R patched results (are the same).

> Sys.setenv(TZ="UTC")
> library(xts)
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

> xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
Error in .Call("fill_window_dups_rev", tmp, .index(x), PACKAGE = "xts") :
  "fill_window_dups_rev" not available for .Call() for package "xts"

> devtools::session_info()
Session info ------------------------------------------------------------------
 setting  value
 version  R version 3.5.1 Patched (2018-10-09 r75424)
 system   x86_64, mingw32
 ui       RTerm
 language (EN)
 collate  English_United States.1252
 tz       UTC
 date     2018-10-11
...
 xts                  * 0.11-2  2018-10-11 Github (joshuaulrich/xts@57b00a3)

Note: if this error can not be reproduced, then please write back to this issue.

AndreMikulec commented 5 years ago

Wild guessing and comparing/constrasting to binsearch that appears in the same file:

binsearch.c

https://github.com/joshuaulrich/xts/blob/e3120c634ba6d1148385922d6a6cdfeab3bfe630/src/binsearch.c

Comparing https://github.com/joshuaulrich/xts/search?q=binsearch&unscoped_q=binsearch to https://github.com/joshuaulrich/xts/search?q=fill_window_dups_rev&unscoped_q=fill_window_dups_rev then maybe maybe the call should be like?

xts:::fill_window_dups_rev
AndreMikulec commented 5 years ago

No That is not it.

xts:::fill_window_dups_rev

Works fine when I load xts into RStudio as a package

> devtools::load_all(".")

Loading xts

> xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
[1] 1

However, from an installed package, it does not.

> devtools::install(".", args = "--preclean --no-multiarch --with-keep.source")
Installing xts

* DONE (xts)
In R CMD INSTALL
Reloading installed xts
> library(xts)
> xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
Error in .Call("fill_window_dups_rev", tmp, .index(x), PACKAGE = "xts") : 
  "fill_window_dups_rev" not available for .Call() for package "xts"

Change

# res <- .Call("fill_window_dups_rev", tmp, .index(x), PACKAGE = "xts")
  res <- xts:::fill_window_dups_rev(tmp, .index(x))
> devtools::load_all(".")
> xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
Error in get(name, envir = asNamespace(pkg), inherits = FALSE) : 
  object 'fill_window_dups_rev' not found
Called from: 
joshuaulrich commented 5 years ago

This looks a lot like you had an older version of xts installed and upgraded to a newer version while the old version was loaded in an active R session. You need to either: 1) re-install after closing all active R sessions, or 2) install the newest xts to a new library and load it from there.

I'm closing this issue, since it's unlikely a problem in xts itself. I'm still happy to try to help if you are still having problems after trying the two things I mentioned.

AndreMikulec commented 5 years ago

Thanks,

I ended up working (badly) around the problem by doing . . .

unloadNamespace("quantmod");unloadNamespace("PerformanceAnalytics");unloadNamespace("TTR");unloadNamespace("xts");devtools::load_all("./xts")
debug(library)
library(quantmod)
# at the right spot
# just before    .getRequiredPackages2(pkgInfo, quietly = quietly)
# do: pkgInfo$Depends$xts <- NULL
library(PerformanceAnalytics)
# at the right spot
# just before    .getRequiredPackages2(pkgInfo, quietly = quietly)
# do: pkgInfo$Depends$xts <- NULL
undebug(library)

# program with require(quantmod), require(PerformanceAnalytics)
rm(list=setdiff(ls(all.names=TRUE),c("con","cid"))); debugSource('W:/R-3.5._/programWithRequires.R');

But, then, I installed brand new R. https://cran.r-project.org/bin/windows/base/rpatched.html This is a combined Windows 32/64 bit binary build R including patches up to 2018-10-10 (r75424).

I installed a brand new quantmod and dependents(xts). Then, I tried and it works correctly:

> Sys.setenv(TZ="UTC")
> library(xts)
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

> xts:::window_idx(x = xts(NA, zoo::as.Date("1948-11-30")), index. = as.POSIXct("1948-11-30"))
[1] 1

So, currently (in my other R), something is interfering with something somewhere. Currently, I am working backwards trying to figure it out.

Thanks.