# NOT RUN {
fileout <- tempfile(fileext = ".pptx")
doc <- read_pptx()
doc <- add_slide(doc, layout = "Two Content",
master = "Office Theme")
doc <- ph_with(x = doc, value = c("Un titre", "Deux titre"),
location = ph_location_left() )
doc <- ph_with(x = doc, value = iris[1:4, 3:5],
location = ph_location_right() )
anyplot <- plot_instr(code = {
barplot(1:5, col = 2:6)
})
doc <- add_slide(doc)
doc <- ph_with(
doc, anyplot,
location = ph_location_fullsize(),
bg = "#00000066", pointsize = 12)
if( require("ggplot2") ){
doc <- add_slide(doc)
gg_plot <- ggplot(data = iris ) +
geom_point(mapping = aes(Sepal.Length, Petal.Length),
size = 3) +
theme_minimal()
doc <- ph_with(x = doc, value = gg_plot,
location = ph_location_fullsize(),
bg = "transparent" )
doc <- ph_with(x = doc, value = "graphic title",
location = ph_location_type(type="title") )
}
doc <- add_slide(doc, layout = "Title and Content",
master = "Office Theme")
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
doc <- ph_with(x = doc, external_img(img.file, 100/72, 76/72),
location = ph_location_right(), use_loc_size = FALSE )
svg_file <- file.path(R.home(component = "doc"), "html/Rlogo.svg")
if( require("rsvg") ){
doc <- ph_with(x = doc, external_img(svg_file),
location = ph_location_left(),
use_loc_size = TRUE )
}
# block list ------
bl <- block_list(
fpar(ftext("hello world", shortcuts$fp_bold(color = "pink"))),
fpar(
ftext("hello", shortcuts$fp_bold()),
ftext("hello", shortcuts$fp_italic(color="red"))
))
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = bl,
location = ph_location_type(type="body") )
# fpar ------
hw <- fpar(ftext("hello world", shortcuts$fp_bold(color = "pink")))
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = hw,
location = ph_location_type(type="body") )
# unordered_list ----
ul <- unordered_list(
level_list = c(1, 2, 2, 3, 3, 1),
str_list = c("Level1", "Level2", "Level2", "Level3", "Level3", "Level1"),
style = fp_text(color = "red", font.size = 0) )
doc <- add_slide(doc)
doc <- ph_with(x = doc, value = ul,
location = ph_location_fullsize() )
print(doc, target = fileout )
# }
Run the code above in your browser using DataLab