Vector Graphics devices for Microsoft PowerPoint and Excel. Functions extending package 'officer' are provided to embed 'DrawingML' graphics into 'Microsoft PowerPoint' presentations and 'Microsoft Excel' workbooks.
rvg
is providing two graphics devices that produces Vector Graphics
outputs in DrawingML format for Microsoft PowerPoint with dml_pptx
and
for Microsoft Excel with dml_xlsx
. Theses formats let users edit the
graphic elements (editable graphics) within PowerPoint or Excel and
have a very good rendering.
These raw XML outputs cannot be used as is. Functions ph_with_vg()
and ph_with_vg_at()
can be used with package officer
to add vector
graphics in PowerPoint documents.
library(rvg)library(ggplot2)library(officer)doc <- read_pptx()doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")doc <- ph_with_vg(doc, code = barplot(1:10), type = "body")print(doc, target = "my_plot.pptx")
Function xl_add_vg()
is the equivalent for Excel workbooks.
doc <- read_xlsx()doc <- xl_add_vg(doc, sheet = "Feuil1", code = print(gg),width = 6, height = 6, left = 1, top = 2 )print(doc, target = "vg.xlsx")
By default, theses graphics are editable, element edition can be
disabled with option editable = FALSE
. For more details, read officer
article
graphics.
You can get the development version from GitHub:
devtools::install_github("davidgohel/rvg")
Install the CRAN version:
install.packages("rvg")
ggplot2::geom_sf
is now supported.type
of function ph_with_vg
now default to "body".dml_docx
is deprecated and will be removed in later versions. It
was maintained for compatibility reasons with package ReporteRs.
As ReporteRs will be removed from CRAN 2018-07-16, this function
has no more reason to exist.add argument ggobj
to ph_with_vg()
and ph_with_vg_at()
.
It can be used as replacement to code=print(gg)
when gg is
a ggplot object.
new function xl_add_vg()
to add vector graphics produced
from R into Excel workbooks. This requires officer >= 0.2.0
.
plot size was truncated to integers
lines with opacity were not displayed