View source: R/ooxml_block_objects.R
plot_instr | R Documentation |
A simple wrapper to capture
plot instructions that will be executed and copied in a document. It produces
an object of class 'plot_instr' with a corresponding method ph_with()
and
body_add_plot()
.
The function enable usage of any R plot with argument code
. Wrap your code
between curly bracket if more than a single expression.
plot_instr(code)
code |
plotting instructions |
ph_with()
, body_add_plot()
Other block functions for reporting:
block_caption()
,
block_list()
,
block_pour_docx()
,
block_section()
,
block_table()
,
block_toc()
,
fpar()
,
unordered_list()
# plot_instr demo ----
anyplot <- plot_instr(code = {
barplot(1:5, col = 2:6)
})
doc <- read_docx()
doc <- body_add(doc, anyplot, width = 5, height = 4)
print(doc, target = tempfile(fileext = ".docx"))
doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(
doc, anyplot,
location = ph_location_fullsize(),
bg = "#00000066", pointsize = 12)
print(doc, target = tempfile(fileext = ".pptx"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.