Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/davidgohel/flextable/llms.txt

Use this file to discover all available pages before exploring further.

as_paragraph() builds a paragraph from one or more chunks. Each cell in a flextable contains exactly one paragraph; a paragraph is an ordered sequence of chunks. The resulting paragraph is passed to compose(), mk_par(), add_header_lines(), add_footer_lines(), or footnote() to set cell content.

Function signature

as_paragraph(..., list_values = NULL)

Parameters

...
chunks | character
required
Chunk elements that define the paragraph content. Plain character strings are automatically converted to chunks via as_chunk(). Supported chunk types include:
  • as_chunk() — formatted text
  • as_b() / as_i() — bold / italic shortcuts
  • as_sub() / as_sup() — subscript / superscript
  • minibar() — inline bar chart
  • as_image() — image
  • gg_chunk() — ggplot
  • as_equation() — equation
  • hyperlink_text() — hyperlink
list_values
list
A list of chunk elements. If supplied, ... is ignored.

Return value

A paragraph object to be used as the value argument in compose(), mk_par(), add_header_lines(), add_footer_lines(), or footnote().

Examples

Mix formatted text with an inline minibar:
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
Build a formatted caption:
ft <- flextable(head(cars))
ft <- set_caption(
  ft,
  as_paragraph(
    as_b("Table: "),
    as_chunk("cars data", props = fp_text_default(font.family = "Cambria"))
  )
)
ft

See also

Build docs developers (and LLMs) love