thomasp85 / patchwork

The Composer of ggplots
https://patchwork.data-imaginist.com
Other
2.42k stars 157 forks source link

Example requires 'gridGraphics' #327

Closed MichaelChirico closed 6 months ago

MichaelChirico commented 10 months ago

https://github.com/thomasp85/patchwork/blob/51a6eff5b71a15da1c04e42aacd111caa6d13041/man/wrap_elements.Rd#L69-L73

This example fails if gridGraphics is missing. Should we wrap the whole example in @examplesIf gridGraphics? Or perhaps it's better to note the requirement more explicitly:

# You can even add base graphics if you pass it as a formula (requires gridGraphics package)
if (requireNamespace("gridGraphics", quietly = TRUE)) {
  p1 + wrap_elements(full = ~ plot(mtcars$mpg, mtcars$disp))

  # Adding a grob or formula directly is equivalent to placing it in `full`
  p1 + ~ plot(mtcars$mpg, mtcars$disp)
}
thomasp85 commented 8 months ago

yeah, last suggestion is good - would you like to make a PR?