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
219 stars 70 forks source link

print.xts produces error if provided with "quote" or "right" arguments #401

Closed WillemMaetens closed 1 year ago

WillemMaetens commented 1 year ago

Description

print.xts() contains code to handle "quote" or "right" arguments by setting them explicitly in the call to print.default(), but in doing so produces an error if they are already in the ellipsis argument:

Error in print.default(y, quote = quote, right = right, ...) : formal argument "quote" (and/or "right") matched by multiple actual arguments.

Expected behavior

No error is produced if "quote" or "right" arguments are included in call to print.xts(). Set "quote" and "right" values in the ellipsis arguments and not explicitly in the call to print.default().

Minimal, reproducible example


data(sample_matrix)
sample.xts <- as.xts(sample_matrix)
print(sample.xts, quote = TRUE)
print(sample.xts, right = TRUE)

### Session Info
R version 4.3.0 (2023-04-21 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] xts_0.13.1 zoo_1.8-12

loaded via a namespace (and not attached):
[1] compiler_4.3.0 tools_4.3.0    grid_4.3.0     lattice_0.21-8
joshuaulrich commented 1 year ago

Thanks for the report. This is definitely a bug.

WillemMaetens commented 1 year ago

If it's useful, I created a branch that solves the issue and also implements xtsAttribute printing functionality in print.xts (was actually doing that when I noticed the bug): https://github.com/WillemMaetens/xts-mods/tree/print.xts

joshuaulrich commented 1 year ago

That was very useful, thank you!