Learn R Programming

flextable (version 0.4.0)

as_image: image wrapper

Description

The function has to be used with function display(). It lets add images within flextable.

Usage

as_image(x, src, width = 1, height = 0.2)

Arguments

x

image will be repeated while iterating this variable. The variable should be one of the original data frame. Note its values are not used, only its size.

src

image filename

width, height

size of the png file in inches

See Also

display

Examples

Run this code
# NOT RUN {
library(officer)
img.file <- file.path( R.home("doc"), "html", "logo.jpg" )
myft <- flextable(head( mtcars, n = 10))
myft <- display(myft,
    i = ~ qsec > 18, col_key = "qsec", pattern = "{{r_logo}}",
    formatters = list( r_logo ~ as_image(qsec,
      src = img.file, width = .20, height = .15)),
    fprops = list(qsec = fp_text(color = "orange")) )
myft
# }

Run the code above in your browser using DataLab