as_paragraph: Concatenate chunks in a flextable

View source: R/05_content.R

as_paragraphR Documentation

Concatenate chunks in a flextable

Description

The function is concatenating text and images within paragraphs of a flextable object, this function is to be used with functions such as compose(), add_header_lines(), add_footer_lines().

This allows the concatenation of formatted pieces of text (chunks) that represent the content of a paragraph.

The cells of a flextable contain each a single paragraph. This paragraph is made of chunks that can be text, images or plots, equations and links.

Usage

as_paragraph(..., list_values = NULL)

Arguments

...

chunk elements that are defining paragraph. If a character is used, it is transformed to a chunk object with function as_chunk().

list_values

a list of chunk elements that are defining paragraph. If specified argument ... is unused.

See Also

as_chunk(), minibar(), as_image(), hyperlink_text()

Other functions for mixed content paragraphs: append_chunks(), compose(), prepend_chunks()

Examples

library(flextable)
ft <- flextable(airquality[sample.int(150, size = 10), ])
ft <- compose(ft,
  j = "Wind",
  value = as_paragraph(
    as_chunk(Wind, props = fp_text_default(color = "orange")),
    " ",
    minibar(value = Wind, max = max(airquality$Wind), barcol = "orange", bg = "black", height = .15)
  ),
  part = "body"
)
ft <- autofit(ft)
ft

flextable documentation built on Oct. 23, 2023, 1:07 a.m.