grid_chunk: 'Grid Graphics' chunk wrapper

View source: R/chunk_images.R

grid_chunkR Documentation

'Grid Graphics' chunk wrapper

Description

This function is used to insert grid objects into flextable with functions:

  • compose() and as_paragraph(),

  • append_chunks(),

  • prepend_chunks().

Usage

grid_chunk(value, width = 1, height = 0.2, unit = "in", res = 300)

Arguments

value

grid objects, stored in a list column; or a list of grid objects.

width, height

size of the resulting png file

unit

unit for width and height, one of "in", "cm", "mm".

res

resolution of the png image in ppi

Note

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.

See Also

Other chunk elements for paragraph: as_b(), as_bracket(), as_chunk(), as_equation(), as_highlight(), as_i(), as_image(), as_sub(), as_sup(), as_word_field(), colorize(), gg_chunk(), hyperlink_text(), linerange(), lollipop(), minibar(), plot_chunk()

Examples

library(flextable)
ft_1 <- flextable(head(cars))
if (require("grid")) {
  ft_1 <- prepend_chunks(
    x = ft_1, i = 2, j = 2,
    grid_chunk(
      list(
        circleGrob(gp = gpar(
          fill = "#ec11c2",
          col = "transparent"
        ))
      ),
      width = .15, height = .15
    )
  )
}
ft_1

flextable documentation built on Oct. 30, 2024, 9:15 a.m.