Skip to content

Error when using function str on a patchwork object #217

@zhangfeiran

Description

@zhangfeiran

After executing:

library(ggplot2)
library(patchwork)

p1 = ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_violin()
p2 = ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_boxplot()
p = p1 + p2
str(p, max.level = 1)

An error shows up:

List of 10
 $ data       :List of 9
  ..- attr(*, "class")= chr [1:2] "gg" "ggplot"
 $ layers     :List of 9
  ..- attr(*, "class")= chr [1:2] "gg" "ggplot"
 $ scales     :
Error: Index out of bounds
Traceback:

1. str(p, max.level = 1)
2. str.default(p, max.level = 1)
3. object[[i]]
4. `[[.patchwork`(object, i)
5. stop("Index out of bounds", call. = FALSE)

Is this some kind of a bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions