
Package index
Create a flextable
Functions to create flextable objects from data frames or other R objects. Start here - flextable() is the main constructor, qflextable() is a quick shortcut, and as_flextable() converts other objects.
-
flextable()qflextable() - Create a flextable from a data frame
-
as_flextable() - Method to transform objects into flextables
-
flextable-package - flextable: Functions for Tabular Reporting
Convert objects to flextable
Transform statistical models, cross-tabulations, and summary tables into flextables. Use tabulator() for pivot-style tables, summarizor() for descriptive statistics, and specific as_flextable methods for models.
-
tabulator()summary(<tabulator>) - Create pivot-style summary tables
-
tabulator_colnames() - Column keys of tabulator objects
-
summarizor() - Prepare descriptive statistics for flextable
-
as_flextable() - Method to transform objects into flextables
-
as_flextable(<compact_summary>) - Transform a 'compact_summary' object into a flextable
-
as_flextable(<data.frame>) - Transform and summarise a 'data.frame' into a flextable Simple summary of a data.frame as a flextable
-
as_flextable(<gam>) - Transform a 'gam' model into a flextable
-
as_flextable(<glm>) - Transform a 'glm' object into a flextable
-
as_flextable(<grouped_data>) - Transform a 'grouped_data' object into a flextable
-
as_flextable(<htest>) - Transform a 'htest' object into a flextable
-
as_flextable(<kmeans>) - Transform a 'kmeans' object into a flextable
-
as_flextable(<lm>) - Transform a 'lm' object into a flextable
-
as_flextable(<merMod>)as_flextable(<lme>)as_flextable(<gls>)as_flextable(<nlme>)as_flextable(<brmsfit>)as_flextable(<glmmTMB>)as_flextable(<glmmadmb>) - Transform a 'merMod' or 'lme' object into a flextable
-
as_flextable(<pam>) - Transform a 'pam' object into a flextable
-
as_flextable(<summarizor>) - Transform a 'summarizor' object into a flextable
-
as_flextable(<table>) - Transform a 'table' object into a flextable
-
as_flextable(<tabular>) - Transform a 'tables::tabular' object into a flextable
-
as_flextable(<tabulator>) - Transform a 'tabulator' object into a flextable
-
as_flextable(<xtable>) - Transform a 'xtable' object into a flextable
-
continuous_summary() - Summarize continuous variables as a flextable
-
compact_summary() - Compact Summary of a Dataset
-
as_grouped_data() - Insert group-label rows into a data frame
-
proc_freq() - Frequency table
-
shift_table() - Create a shift table
Headers, footers and structural changes
Add or modify header rows, footer rows, or body rows. Set column labels. Remove rows, columns, or entire parts (header, body, footer) from the table.
-
add_header_row() - Add a header row with spanning labels
-
add_header_lines() - Add full-width rows to the header
-
add_header() - Add header rows with one value per column
-
add_footer_row() - Add a footer row with spanning labels
-
add_footer_lines() - Add full-width rows to the footer
-
add_footer() - Add footer rows with one value per column
-
add_body() - Add body rows with one value per column
-
add_body_row() - Add a body row with spanning labels
-
separate_header() - Split column names using a separator into multiple rows
-
set_header_labels() - Rename column labels in the header
-
set_header_df()set_footer_df() - Replace the entire header or footer from a data frame
-
delete_part() - Delete flextable part
-
delete_rows() - Delete flextable rows
-
delete_columns() - Delete flextable columns
Merge cells
Combine adjacent cells horizontally or vertically to create spanning cells. Useful for grouped headers or repeated values.
-
merge_at() - Merge flextable cells into a single one
-
merge_h() - Merge flextable cells horizontally
-
merge_h_range() - Rowwise merge of a range of columns
-
merge_none() - Delete flextable merging information
-
merge_v() - Merge flextable cells vertically
Format cell values
Control how values are displayed: number of decimals, date formats, thousand separators, currency symbols. Use colformat_* functions for column-wide formatting.
-
colformat_char() - Format character cells
-
colformat_date() - Format date cells
-
colformat_datetime() - Format datetime cells
-
colformat_double() - Format double cells
-
colformat_image() - Format cells as images
-
colformat_int() - Format integer cells
-
colformat_lgl() - Format logical cells
-
colformat_num() - Format numeric cells with format()
-
set_formatter() - Set column formatter functions
-
labelizor() - Replace displayed text with labels
Compose rich content
Create cells with mixed content: combine text, images, plots, and formatted chunks in a single cell. Use compose() with as_paragraph().
-
compose()mk_par() - Set cell content from paragraph chunks
-
as_paragraph() - Build a paragraph from chunks
-
append_chunks() - Append chunks to flextable content
-
prepend_chunks() - Prepend chunks to flextable content
-
footnote() - Add footnotes to flextable
Content chunks
Building blocks for rich cell content. Use inside as_paragraph() or compose(): text formatting (as_b, as_i), images (as_image, gg_chunk), links (hyperlink_text), equations (as_equation).
-
as_chunk() - Text chunk
-
as_b() - Bold chunk
-
as_i() - Italic chunk
-
as_strike() - Strikethrough chunk
-
as_sub() - Subscript chunk
-
as_sup() - Superscript chunk
-
as_highlight() - Highlight chunk
-
colorize() - Colorize chunk
-
as_qmd() - Quarto inline markdown chunk
-
as_bracket() - Bracket chunk
-
hyperlink_text() - Hyperlink chunk
-
as_equation() - Equation chunk
-
as_word_field() - Word dynamic field chunk
-
as_image() - Image chunk
-
gg_chunk() - ggplot chunk
-
plot_chunk() - Mini plot chunk
-
grid_chunk() - Grid Graphics chunk
-
minibar() - Mini barplot chunk
-
linerange() - Mini linerange chunk
Apply themes
Apply predefined visual themes to quickly style the entire table. Themes set fonts, colors, borders, and padding in one call.
-
theme_alafoli() - Apply alafoli theme
-
theme_apa() - Apply APA theme
-
theme_booktabs() - Apply booktabs theme
-
theme_borderless() - Apply borderless theme
-
theme_box() - Apply box theme
-
theme_tron() - Apply tron theme
-
theme_tron_legacy() - Apply tron legacy theme
-
theme_vader() - Apply Sith Lord Darth Vader theme
-
theme_vanilla() - Apply vanilla theme
-
theme_zebra() - Apply zebra theme
Style text and cells
Control typography and cell appearance: font family, size, color, bold, italic, background color, text highlighting.
-
style() - Set formatting properties on a flextable selection
-
font() - Set font
-
fontsize() - Set font size
-
bold() - Set bold font
-
italic() - Set italic font
-
color() - Set font color
-
highlight() - Set text highlight color
-
bg() - Set background color
-
fp_text_default() - Create text formatting with flextable defaults
Alignment and spacing
Control text alignment (left, center, right), vertical alignment, cell padding, line spacing, and text rotation.
-
align()align_text_col()align_nottext_col() - Set text alignment
-
valign() - Set vertical alignment
-
padding() - Set paragraph paddings
-
line_spacing() - Set line spacing
-
rotate() - Rotate cell text
-
tab_settings() - Set tabulation marks configuration
-
empty_blanks() - Make blank columns transparent
Borders
Add, remove, or customize cell borders. Use hline/vline for single lines, border_inner/border_outer for bulk operations, surround for highlighting.
-
fp_border_default() - Create border formatting with flextable defaults
-
hline() - Set horizontal borders below selected rows
-
hline_bottom() - Set the bottom border of a table part
-
hline_top() - Set the top border of a table part
-
vline() - Set vertical borders to the right of selected columns
-
vline_left() - Set the left border of the table
-
vline_right() - Set the right border of the table
-
border_inner() - Set all inner borders
-
border_inner_h() - Set inner horizontal borders
-
border_inner_v() - Set inner vertical borders
-
border_outer() - Set outer borders
-
border_remove() - Remove borders
-
surround() - Surround cells with borders
Table and column dimensions
Control table width, column widths, and automatic sizing. Use autofit() for automatic adjustment, width() for manual control.
-
width() - Set columns width
-
autofit() - Adjust cell widths and heights
-
fit_to_width() - Fit a flextable to a maximum width
-
set_table_properties() - Set table layout and width properties
Row height and pagination
Control row heights and how tables break across pages. Use paginate() to split long tables, keep_with_next to prevent orphan rows.
-
height()height_all() - Set flextable rows height
-
hrule() - Set how row heights are determined
-
paginate() - Prevent page breaks inside a flextable
-
keep_with_next() - Set Word 'Keep with next' instructions
Get dimensions
Query table dimensions: number of rows, columns, pixel sizes. Useful for dynamic layouts and conditional formatting.
-
dim(<flextable>) - Get column widths and row heights of a flextable
-
dim_pretty() - Calculate optimal column widths and row heights
-
flextable_dim() - Get overall width and height of a flextable
-
nrow_part() - Number of rows of a part
-
ncol_keys() - Number of columns
Caption and labels
Add table captions for cross-referencing in documents. Captions appear above or below the table and can be numbered automatically.
-
set_caption() - Set flextable caption
Save to files
Export flextables to standalone files: Word (.docx), PowerPoint (.pptx), HTML, RTF, or images (PNG, PDF, SVG).
-
save_as_docx() - Save flextable objects in a 'Word' file
-
save_as_pptx() - Save flextable objects in a 'PowerPoint' file
-
save_as_html() - Save flextable objects in an 'HTML' file
-
save_as_rtf() - Save flextable objects in an 'RTF' file
-
save_as_image() - Save a flextable in a 'png' or 'svg' file
Integrate with R Markdown and Quarto
Functions for rendering flextables in R Markdown, Quarto, and knitr documents. Automatic rendering is usually handled by knit_print.
-
use_flextable_qmd() - Install the flextable-qmd Quarto extension
-
knit_print(<flextable>) - Render flextable in knitr documents
-
flextable_to_rmd() - Print a flextable inside knitr loops and conditionals
-
df_printer() - data.frame automatic printing as a flextable
-
use_df_printer() - Set data.frame automatic printing as a flextable
-
use_model_printer() - Set automatic flextable printing for models
Integrate with officer (Word/PowerPoint)
Add flextables to Word and PowerPoint documents created with the officer package. Use body_add_flextable for Word, ph_with for PowerPoint.
-
body_add_flextable() - Add flextable into a Word document
-
body_replace_flextable_at_bkm() - Add flextable at bookmark location in a Word document
-
ph_with(<flextable>) - Add a flextable into a PowerPoint slide
-
rtf_add(<flextable>) - Add a 'flextable' into an RTF document
-
print(<flextable>) - Print a flextable
-
to_html(<flextable>) - Get HTML code as a string
-
htmltools_value() - Convert a flextable to an HTML object
-
wrap_flextable() - Wrap a flextable for use with patchwork
-
plot(<flextable>) - Plot a flextable
-
gen_grob() - Render a flextable as a graphic object
-
plot(<flextableGrob>) - plot a flextable grob
-
dim(<flextableGrob>) - Get optimal width and height of a flextable grob
Global defaults
Set default formatting options that apply to all new flextables: fonts, colors, borders, padding. Reduces repetitive code.
-
set_flextable_defaults()init_flextable_defaults() - Modify flextable defaults formatting properties
-
get_flextable_defaults() - Get flextable defaults formatting properties
Utilities
Helper functions for conditional display (void), row positioning (before), and value formatting (fmt_*).
-
fmt_2stats()fmt_summarizor() - Format summarizor statistics as text
-
fmt_avg_dev() - Format mean and standard deviation as text
-
fmt_dbl() - Format numbers as doubles
-
fmt_header_n() - Format count as '(N=XX)' for column headers
-
fmt_int() - Format numbers as integers
-
fmt_n_percent() - Format count and percentage as text
-
fmt_pct() - Format numbers as percentages
-
fmt_signif_after_zeros() - Format with significant figures after zeros
-
before() - Detect rows before a given value
-
void() - Clear the displayed content of selected columns