Error printing short ts objects in a Jupyter notebook
Closed this issue · 1 comments
bachmeil commented
When using a Jupyter notebook with R kernel in CoCalc to print out a ts object, I got this error
ERROR while rich displaying an object: Error in arr_partition(a, rows, cols): rows >= 2L is not TRUE
The error occurs when printing a ts object where all observations are in the same year. To replicate in a notebook:
# This works fine because two rows of output
ts(rnorm(13), start=c(2000,1), frequency=12)
# This fails because only one row of output
ts(rnorm(12), start=c(2000,1), frequency=12)
# Wrapping in a print statement works, but that's because it's dumping the R output directly to the screen rather than formatting it
print(ts(rnorm(12), start=c(2000,1), frequency=12))
It looks like the message is triggered by this line, which imposes the requirement that the ts object has to have two rows:
Line 36 in e82a319
flying-sheep commented
Ah right, those parameters are supposed to control the max number of rows/cols that are displayed before ellipses (…) indicate omission. Time series should always fully display, so I overrode the max number of rows/cols to be the actual number there, forgetting that the ellipsis code can’t handle that.