Skip to content

Extraneous positioning dataframe emitted when combining grobs in Rmarkdown notebooks #231

Closed

Description

@davidski

As always, thank you so much for the wonderful packages!

Under patchwork 1.1.1 (sessioninfo here: sessioninfo.txt), all the grob combination operations I can think of (+, /, wrap_plots(), etc). print the positioning frame when run in the context of a RMarkdown notebook. This dataframe is not output when run from the console.

The constructed patchwork object otherwise works as expected, so this is a display issue when generating notebooks rather than a critical functionality issue.

Issue has been replicated via the R4DS Slack community as well.

library(ggplot2)
library(patchwork)
gg1 <- ggplot(mtcars, aes(mpg, cyl)) + 
  geom_point()

gg2 <- ggplot(mtcars, aes(hp, disp)) + 
  geom_point()

foo <- gg1 + gg2 + plot_layout(ncol = 1)

Screen Shot 2021-01-08 at 11 26 45 AM

Activity

  1. changed the title [-]Extraneous posiitoning dataframe emitted when combining grobs in Rmarkdown notebooks[/-] [+]Extraneous positioning dataframe emitted when combining grobs in Rmarkdown notebooks[/+] on Jan 8, 2021
  2. vadimus202 commented on Jan 19, 2021

    @vadimus202

    I noticed the same issue after upgrading some tidyverse packages. The data frame only prints during assignment of combined plots to a variable.

  3. rspreafico commented on Feb 1, 2021

    @rspreafico

    Same here

  4. davidski commented on Jun 6, 2021

    @davidski
    Author

    @thomasp85 Any chance you could give a pointer on where to look to debug this issue? I'm happy to give a stab and identifying the root problem but am having a bit of uphill climb on understanding the flow of what's involved in this issue. Any debug guide you could give would be super appreciated. I'd love to get this issue fixed!

  5. thomasp85 commented on Aug 2, 2021

    @thomasp85
    Owner

    Hum... this looks super weird and I have no idea on top of my head for where the issue is

    I'm sure I can fix this when I get around to it, but I'm afraid I wouldn't know how to guide others in the meantime

  6. davidski commented on Aug 2, 2021

    @davidski
    Author

    Very much appreciated! If there is any support we can give from a user side, please don't hesitate to ask. This particular issue is a personal bit of grit in my eye that I'd like to remove. 😄

  7. added
    bug
    on Aug 8, 2023
  8. kevinushey commented on Aug 8, 2023

    @kevinushey
    Contributor

    I've taken a look, and it looks like a bug in RStudio. To explain the behavior:

    1. When executing a Notebook chunk, RStudio inserts its own print() overrides, so that it can detect and capture attempts to print R objects. This is what allows RStudio to capture e.g. data.frame print-outs in a clean way.
    2. RStudio also tries to detect changes to objects in the Environment pane as code chunks are executed. When new objects are created, or changed, we try to introspect those new objects to learn a bit more about those objects.
    3. To that end, when inspecting the foo object, we call str(foo) -- but this involves calling print() when examining some of the internal data in foo.
    4. Unfortunately, because the print() overrides in (1) are still active, we end up inadvertently capturing that output into the Notebook chunk.

    I think we can fix this on the RStudio side by making sure we deactivate our print overrides when updating the Environment pane.

  9. thomasp85 commented on Aug 11, 2023

    @thomasp85
    Owner

    Thanks @kevinushey — I'm going to close it here as there is nothing more to do on the patchwork side of things

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions