These functions add or remove header and footer rows in a flextable, and provide tools for splitting compound column names into multi-row headers.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.
add_header_row()
Add a single row to the header where labels can span multiple columns.A
flextable object.Insert the row at the top (
TRUE) or bottom (FALSE) of the existing header.Labels to add. A character vector, a list, or a call to
as_paragraph() for formatted content. The number of labels must match the number of span groups defined by colwidths.Number of columns each label spans. Must sum to the total number of columns. Defaults to one column per label.
Example
add_header_lines()
Add one or more full-width rows to the header. Each label spans all columns.A
flextable object.A character vector or a call to
as_paragraph(). Each element becomes a separate full-width row.Insert rows at the top (
TRUE) or bottom (FALSE) of the existing header.Example
add_header()
Add a header row where each value maps to a named column. Unlikeadd_header_row(), values fill exactly one column.
A
flextable object.Insert the row at the top or bottom of the existing header.
Named arguments where names are column keys and values are the labels to insert.
A named list of column key-value pairs. If supplied,
... is ignored.Example
add_footer_row()
Add a single row to the footer where labels can span multiple columns.A
flextable object.Insert the row at the top or bottom of the existing footer.
Labels to add. A character vector, a list, or a call to
as_paragraph().Number of columns each label spans. Must sum to the total number of columns.
Example
add_footer_lines()
Add one or more full-width rows to the footer. Each label spans all columns.A
flextable object.A character vector or a call to
as_paragraph(). Each element becomes a separate full-width row.Insert rows at the top (
TRUE) or bottom (FALSE) of the existing footer.Example
add_footer()
Add a footer row where each value maps to a named column.A
flextable object.Insert the row at the top or bottom of the existing footer.
Named arguments where names are column keys and values are the labels to insert.
A named list of column key-value pairs. If supplied,
... is ignored.Example
delete_part()
Remove an entire part (header, footer, or body) from a flextable.A
flextable object.The part to remove:
"header", "footer", or "body".Example
separate_header()
Split compound column names (e.g.,Sepal.Length or Sepal_Length) into multiple header rows using a separator.
A
flextable object. Must have only one header row when this function is called.Optional post-processing operations as a character vector:
"span-top"— span empty cells upward with the first non-empty cell, column by column."center-hspan"— center cells that are horizontally spanned."bottom-vspan"— align to the bottom cells affected by"span-top"."default-theme"— apply the theme set inset_flextable_defaults(theme_fun = ...)to the new header.
A regular expression used to split column names. Default splits on underscores and dots.
If
TRUE, treat split as a fixed string rather than a regular expression.Example
Return value
All functions return the modifiedflextable object.
See also
set_header_labels()— rename individual column labelsset_header_df()— replace the entire header from a data framefootnote()— add footnotes to the footermerge_h(),merge_v()— merge header cells