Skip to content

Conversation

@BFalquet
Copy link
Contributor

@BFalquet BFalquet commented Jan 23, 2026

close #14

This pull request expands the functionality of the save_with_rmarkdown function to support saving ggplot and grid graphics objects (in addition to tables) to a docx file.

Expanded object support and refactoring:

  • Introduced a new function accepted_object_classes (replacing accepted_table_classes) to define accepted S3 classes, now including "gg", "ggplot", and "grob" alongside table classes. (R/accepted_object_classes.R [1] R/accepted_table_classes.R [2] NAMESPACE [3] man/accepted_object_classes.Rd [4] man/accepted_table_classes.Rd [5]
  • Updated save_with_rmarkdown to accept and correctly process ggplot2 and grid graphics objects, as well as lists containing any combination of supported objects. (R/save_with_rmarkdown.R [1] [2] [3]

Dependency and documentation updates:

  • Added ggplot2 to the package Suggests field to support new functionality. (DESCRIPTION DESCRIPTIONR24)

Testing:

Internal logic improvements:

  • Enhanced logic for attaching required packages in the R Markdown header, mapping object classes to their respective packages (e.g., "ggplot"/"gg" to "ggplot2", "grob" to "grid"). (R/save_with_rmarkdown.R R/save_with_rmarkdown.RL72-R88)

@BFalquet BFalquet requested a review from Melkiades January 23, 2026 10:31
@@ -0,0 +1,10 @@
#' Accepted Object S3 Classes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like this too much. I suggest doing a file accepted_classes() with both accepted_table_classes() and accepted_plot_classes(). I wonder if these should be internal nonetheless.... Do we expect users to use this directly?

Suggests:
cards,
flextable,
ggplot2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe grid missing?

Copy link
Contributor

@Melkiades Melkiades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job Benoit! I have only a minor suggestion about the help function ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for plots (ggplot, grob, base R plots)

2 participants