-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpptx_plot_export.R
27 lines (26 loc) · 1.11 KB
/
pptx_plot_export.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# function to generate vectorized pptx
library(rvg)
library(officer)
gen_pptx <- function(plot, file, height = 5, width = 5, left = 1, top = 1) {
read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with(value = dml(ggobj = plot),
location = ph_location(height = height, width = width,
left = left, top = top),
bg = "transparent") %>%
print(target = file)
}
# function to generate combined static/vectorized ppt
gen_statvect_pptx <- function(static, vectorized, file, height = 5, width = 5, left = 1, top = 1) {
read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_with(value = static,
location = ph_location(height = height, width = width,
left = left, top = top),
bg = "transparent") %>%
ph_with(value = dml(ggobj = vectorized),
location = ph_location(height = height, width = width,
left = left, top = top),
bg = "transparent") %>%
print(target = file)
}