Closed HughParsonage closed 6 years ago
if statement in R/xts.R may use length > 1 objects and so may cause an warning/error if the _R_CHECK_LENGTH_1_LOGIC2_ is set or at the very least silently ignore other elements of class(order.by).
if
R/xts.R
_R_CHECK_LENGTH_1_LOGIC2_
class(order.by)
No warning or error
library(xts) library(data.table) Sys.setenv("_R_CHECK_LENGTH_1_LOGIC2_" = TRUE) dt = data.table(index = as.POSIXct((as.Date("2014-12-12")-49):as.Date("2014-12-12"), origin="1970-01-01"), quantity = as.numeric(rep(c(1:5),10)), value = rep(c(1:10)*100,5)) xt = as.xts(matrix(data = c(dt$quantity, dt$value), ncol = 2, dimnames = list(NULL,c("quantity","value"))), order.by = dt$index) #> Error in orderBy == "timeDate" && missing(tzone): 'length(x) = 2 > 1' in coercion to 'logical(1)'
R Under development (unstable) (2018-09-23 r75355) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17134) Matrix products: default locale: [1] LC_COLLATE=English_Australia.1252 LC_CTYPE=English_Australia.1252 [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C [5] LC_TIME=English_Australia.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] xts_0.11-1 zoo_1.8-4 data.table_1.11.6 loaded via a namespace (and not attached): [1] compiler_3.6.0 grid_3.6.0 lattice_0.20-35
Description
if
statement inR/xts.R
may use length > 1 objects and so may cause an warning/error if the_R_CHECK_LENGTH_1_LOGIC2_
is set or at the very least silently ignore other elements ofclass(order.by)
.Expected behavior
No warning or error
Minimal, reproducible example
Session Info