Skip to content

Error printing short ts objects in a Jupyter notebook #134

Description

@bachmeil

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:

stopifnot(rows >= 2L, cols >= 2L)

Activity

  1. flying-sheep commented on Sep 6, 2020

    @flying-sheep
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions