Learn R Programming

flextable (version 0.9.11)

as_paragraph: Build a paragraph from chunks

Description

as_paragraph() assembles one or more chunks into a single paragraph that defines the content of a flextable cell. Each cell in a flextable contains exactly one paragraph; a paragraph is an ordered sequence of chunks.

Chunks are the smallest content units and can be created with as_chunk() (formatted text), as_b() / as_i() (bold / italic shortcuts), minibar() (inline bar), as_image() (image), gg_chunk() (ggplot), as_equation() (equation) or hyperlink_text() (link). Plain character strings passed to as_paragraph() are automatically converted to chunks via as_chunk().

The resulting paragraph is passed to the value argument of compose(), mk_par(), add_header_lines(), add_footer_lines() or footnote() to set cell content.

Usage

as_paragraph(..., list_values = NULL)

Arguments

...

chunk elements that are defining the paragraph content. 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 the paragraph content. 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

Run this code
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

Run the code above in your browser using DataLab