shift.time: no applicable method for 'shift.time #268
shift.time is an exported function of xts, but if you try to use it, it will result in an error.
shift.time.xts is the underlying function called when you have an xts object and you want to shift the time by n seconds.
I found that the reason why this doesn't work is that shift.time.xts is not exported as an s3 method in the namespace. Adding
Minimal, reproducible example
Following code will result in the error
df1 <- data.frame(dates = Sys.time() + 1:10, values = 1:10) df1_xts <- xts(df1$values, order.by = df1$dates) shift.time(df1_xts, n = 60)
using the following code, the shift works
R version 3.5.0 (2018-04-23) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale:  LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252  LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252 attached base packages:  stats graphics grDevices utils datasets methods base other attached packages:  xts_0.11-1 zoo_1.8-4 loaded via a namespace (and not attached):  compiler_3.5.0 tools_3.5.0 yaml_2.2.0 grid_3.5.0 lattice_0.20-35
The text was updated successfully, but these errors were encountered: