as_image | R Documentation |
The function lets add images within flextable objects with functions:
compose()
and as_paragraph()
,
append_chunks()
,
prepend_chunks()
as_image(src, width = NULL, height = NULL, unit = "in", guess_size = TRUE, ...)
src |
image filename |
width , height |
size of the image file. It can be ignored
if parameter |
unit |
unit for width and height, one of "in", "cm", "mm". |
guess_size |
If package 'magick' is installed, this option
can be used (set it to |
... |
unused argument |
This chunk option requires package officedown in a R Markdown context with Word output format.
PowerPoint cannot mix images and text in a paragraph, images are removed when outputing to PowerPoint format.
compose()
, as_paragraph()
Other chunk elements for paragraph:
as_b()
,
as_bracket()
,
as_chunk()
,
as_equation()
,
as_highlight()
,
as_i()
,
as_sub()
,
as_sup()
,
as_word_field()
,
colorize()
,
gg_chunk()
,
grid_chunk()
,
hyperlink_text()
,
linerange()
,
lollipop()
,
minibar()
,
plot_chunk()
img.file <- file.path(
R.home("doc"),
"html", "logo.jpg"
)
if (require("magick")) {
myft <- flextable(head(iris))
myft <- compose(myft,
i = 1:3, j = 1,
value = as_paragraph(
as_image(src = img.file),
" ",
as_chunk(Sepal.Length,
props = fp_text_default(color = "red")
)
),
part = "body"
)
ft <- autofit(myft)
ft
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.