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 71 forks source link

Issue with new print feature in xts 0.13.0 #397

Closed cactus74 closed 1 year ago

cactus74 commented 1 year ago

Description

It looks like the latest enhancement to print xts (looking like data.table) has an issue with xts wider than the terminal window.

Expected behavior

While for a small number of columns everything is fine, with a larger one xts print returns a not very helpful error. Please note the error occurs with less than 100 rows too.

u=matrix(0, nrow=150, ncol=5)
v=xts(u,order.by=as.Date(seq(1,150)))
v
           [,1] [,2] [,3] [,4] [,5]
1970-01-02    0    0    0    0    0
1970-01-03    0    0    0    0    0
1970-01-04    0    0    0    0    0
1970-01-05    0    0    0    0    0
1970-01-06    0    0    0    0    0
1970-01-07    0    0    0    0    0
1970-01-08    0    0    0    0    0
1970-01-09    0    0    0    0    0
1970-01-10    0    0    0    0    0
1970-01-11    0    0    0    0    0
       ...                         
1970-05-22    0    0    0    0    0
1970-05-23    0    0    0    0    0
1970-05-24    0    0    0    0    0
1970-05-25    0    0    0    0    0
1970-05-26    0    0    0    0    0
1970-05-27    0    0    0    0    0
1970-05-28    0    0    0    0    0
1970-05-29    0    0    0    0    0
1970-05-30    0    0    0    0    0
1970-05-31    0    0    0    0    0

u=matrix(0, nrow=150, ncol=50)
v=xts(u,order.by=as.Date(seq(1,150)))
v
Error in dimnames(x) <- dn : 
  length of 'dimnames' [2] not equal to array extent
`
### Minimal, reproducible example

```r
u=matrix(0, nrow=150, ncol=40)
v=xts(u,order.by=as.Date(seq(1,150)))
v

Session Info

R version 4.2.2 Patched (2022-11-10 r83330)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.2 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.utf8       LC_NUMERIC=C             
 [3] LC_TIME=en_US.utf8        LC_COLLATE=en_US.utf8    
 [5] LC_MONETARY=en_US.utf8    LC_MESSAGES=en_US.utf8   
 [7] LC_PAPER=en_US.utf8       LC_NAME=C                
 [9] LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C      

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

other attached packages:
[1] xts_0.13.0 zoo_1.8-11

loaded via a namespace (and not attached):
[1] compiler_4.2.2  tools_4.2.2     grid_4.2.2      lattice_0.20-45
cactus74 commented 1 year ago

Sorry, I see it was already announced. Missed it in the filter just seeing open issues.