Skip to content

Assigning patchwork object to variable produces extra dataframe output in RStudio R Markdown #443

@jawhiteley

Description

@jawhiteley

I'm not sure if this is an issue with patchwork or RStudio, but I have only encountered this with patchwork so far.

When I assign a patchwork object to a variable within a code chunk in an R Markdown document, it produces a dataframe output that is unexpected. I cannot suppress it with invisible(), or by setting the chunk option include=FALSE. This output does not happen with the same expression in the console. Fortunately, this output is also not included in output documents when the R Markdown file is knit()ed or render()ed. So it's not serious, but a minor annoyance and somewhat alarming the first time it happens.

As an example, I was able to reproduce this behaviour with the code in this StackOverflow answer.

Image

RStudio version: 2024.12.0 Build 467
SessionInfo:

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
  [1] LC_COLLATE=English_Canada.utf8  LC_CTYPE=English_Canada.utf8    LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C                   
[5] LC_TIME=English_Canada.utf8    

time zone: America/Toronto
tzcode source: internal

attached base packages:
  [1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
  [1] patchwork_1.3.1 lubridate_1.9.4 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4     purrr_1.1.0     readr_2.1.5     tidyr_1.3.1    
[9] tibble_3.3.0    ggplot2_3.5.2   tidyverse_2.0.0

loaded via a namespace (and not attached):
  [1] gtable_0.3.6       compiler_4.4.1     tidyselect_1.2.1   scales_1.4.0       yaml_2.3.10        fastmap_1.2.0     
[7] R6_2.6.1           generics_0.1.4     knitr_1.49         pillar_1.11.0      RColorBrewer_1.1-3 tzdb_0.4.0        
[13] rlang_1.1.6        stringi_1.8.7      xfun_0.49          timechange_0.3.0   cli_3.6.5          withr_3.0.2       
[19] magrittr_2.0.3     digest_0.6.37      grid_4.4.1         rstudioapi_0.17.1  hms_1.1.3          lifecycle_1.0.4   
[25] vctrs_0.6.5        evaluate_1.0.4     glue_1.8.0         farver_2.1.2       rmarkdown_2.29     tools_4.4.1       
[31] pkgconfig_2.0.3    htmltools_0.5.8.1 

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