Skip to content

Error printing short ts objects in a Jupyter notebook #134

@bachmeil

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions