R: image wrapper

as_image {flextable} | R Documentation

## 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

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

[Package flextable version 0.4.5 Index]