Learn R Programming

⚠️There's a newer version (0.9.5) of this package.Take me there.

flextable R package

The user documentation is available here: https://ardata-fr.github.io/flextable-book/

set_flextable_defaults(
  font.family = "Arial", font.size = 10, 
  border.color = "gray")

flextable(head(cars)) %>% 
  bold(part = "header") %>% 
  add_footer_lines("The 'cars' dataset")

Tables can be embedded within HTML, PDF, Word and PowerPoint documents from R Markdown documents and within Microsoft Word or PowerPoint documents with package officer. Tables can also be rendered as R plots or graphic files (png, pdf and jpeg).

flextable(mtcars) %>% 
  theme_vanilla() %>% 
  save_as_docx(path = "mytable.docx")

A flextable object is a data.frame representation. An API is available to let R users create tables for reporting and control their formatting properties and their layout. The package provides functions that give control over:

  • header, body and footer content
  • text, paragraphs, cells and border formatting of any element
  • displayed values

Installation

install.packages("flextable")

You can get the development version from GitHub:

devtools::install_github("davidgohel/flextable")

Resources

Documentation

The help pages are in a bookdown located at: https://ardata-fr.github.io/flextable-book/

Manuals are available at: https://davidgohel.github.io/flextable/reference/index.html

A gallery of examples is available here: https://ardata.fr/en/flextable-gallery/

Getting help / questions

If you have questions about how to use the package, visit Stackoverflow and use tags flextable and r Stackoverflow link! You can also use https://github.com/davidgohel/flextable/discussions to start a discussion.

Contributing to the package

Code of Conduct

Anyone getting involved in this package agrees to our Code of Conduct.

Bug reports

When you file a bug report, please spend some time making it easy for me to follow and reproduce. The more time you spend on making the bug report coherent, the more time I can dedicate to investigate the bug as opposed to the bug report.

Contributing to the package development

A great way to start is to contribute an example or improve the documentation.

If you want to submit a Pull Request to integrate functions of yours, please provide:

  • the new function(s) with code and roxygen tags (with examples)
  • a new section in the appropriate vignette that describes how to use the new function
  • corresponding tests in directory tests/testthat.

By using rhub (run rhub::check_for_cran()), you will see if everything is ok. When submitted, the PR will be evaluated automatically on travis and appveyor and you will be able to see if something broke.

Copy Link

Version

Install

install.packages('flextable')

Monthly Downloads

82,872

Version

0.8.4

License

GPL-3

Maintainer

David Gohel

Last Published

January 21st, 2023

Functions in flextable (0.8.4)

add_footer_lines

Add labels as new rows in the footer
add_footer

Add column values as new lines in footer
add_body

Add column values as new lines in body
as_equation

equation chunk
as_chunk

chunk of text wrapper
append_chunks

append chunks to flextable content
as_flextable

method to convert object to flextable
as_flextable.data.frame

Printing data.frame summary as a flextable
as_flextable.grouped_data

tabular summary for grouped_data object
as_flextable.glm

tabular summary for glm object
as_bracket

chunk with values in brackets
as_b

bold chunk
as_flextable.gam

tabular summary for gam object
as_flextable.pam

tabular summary for pam
as_flextable.lm

tabular summary for lm object
as_flextable.merMod

tabular summary for mixed model
as_flextable.summarizor

summarizor to flextable
as_flextable.htest

tabular summary for htest object
as_flextable.xtable

get a flextable from a xtable object
as_flextable.tabulator

tabulator to flextable
as_grouped_data

grouped data transformation
as_flextable.kmeans

tabular summary for kmeans
as_highlight

highlight chunk
as_image

image chunk wrapper
as_sub

subscript chunk
as_word_field

'Word' computed field
bg

Set background color
as_i

italic chunk
as_paragraph

concatenate chunks in a flextable
as_raster

get a flextable as a raster
before

is an element before a match with entries
autofit

Adjusts cell widths and heights
as_sup

superscript chunk
border

cell borders update
border_remove

remove borders
border_inner

set vertical & horizontal inner borders
colformat_char

format character cells
border_outer

set outer borders
border_inner_v

set vertical inner borders
bold

Set bold font
body_add_flextable

add flextable into a Word document
border_inner_h

set inner borders
chunk_dataframe

create a chunk representation suitable for flextable
colformat_date

format date cells
colformat_datetime

format datetime cells
colformat_image

format cells as images
colformat_double

format numeric cells
color

Set font color
colformat_num

format numeric cells
df_printer

data.frame automatic printing as a flextable
dim.flextable

Get widths and heights of flextable
fix_border_issues

fix border issues when cell are merged
flextable-package

flextable: Functions for Tabular Reporting
colformat_lgl

format logical cells
continuous_summary

continuous columns summary
font

Set font
colformat_int

format integer cells
fontsize

Set font size
delete_part

delete flextable part
compose

Define displayed values and mixed content
fmt_avg_dev

format content for mean and sd
empty_blanks

make blank columns as transparent
colorize

colorize chunk
fmt_2stats

format content for data generated with summarizor()
fit_to_width

fit a flextable to a maximum width
flextable_dim

width and height of a flextable object
flextable

flextable creation
dim_pretty

Calculate pretty dimensions
flextable_html_dependency

htmlDependency for flextable objects
flextable_to_rmd

flextable raw code
dim.flextableGrob

Get optimal width and height of a flextable grob
fmt_header_n

format count data for headers
fmt_n_percent

format content for count data
headers_flextable_at_bkm

add flextable at a bookmark location in document's header
fp_border_default

Border formatting properties
fp_text_default

Text formatting properties
hline

set horizontal borders
highlight

Text highlight color
height

Set flextable rows height
hyperlink_text

Chunk of text with hyperlink
footnote

add footnotes to flextable
footers_flextable_at_bkm

add flextable at a bookmark location in document's footer
italic

Set italic font
get_flextable_defaults

Get flextable defaults formatting properties
gen_grob

Convert a flextable to a grid grob object
htmltools_value

flextable as an HTML object
gg_chunk

ggplots chunk wrapper
knit_print.flextable

Render flextable in rmarkdown
hrule

Set flextable rule for rows heights
hline_top

set top horizontal border
hline_bottom

set bottom horizontal border
grid_chunk

'Grid Graphics' chunk wrapper
labelizor

change displayed labels
merge_h

Merge flextable cells horizontally
merge_at

Merge flextable cells into a single one
lollipop

mini lollipop chart chunk wrapper
merge_h_range

rowwise merge of a range of columns
ncol_keys

Number of columns
minibar

mini barplots chunk wrapper
line_spacing

Set text alignment
linerange

mini linerange chunk wrapper
proc_freq

frequency table as flextable
merge_v

Merge flextable cells vertically
regulartable

flextable old functions
merge_none

Delete flextable merging informations
ph_with.flextable

add a flextable into a PowerPoint slide
plot.flextable

plot a flextable
padding

Set paragraph paddings
nrow_part

Number of rows of a part
print.flextable

flextable printing
prepend_chunks

prepend chunks to flextable content
save_as_pptx

save flextable objects in an PowerPoint file
rotate

rotate cell text
set_formatter

set column formatter functions
separate_header

Separate collapsed colnames into multiple rows
set_caption

Set Caption
plot_chunk

mini plots chunk wrapper
set_flextable_defaults

Modify flextable defaults formatting properties
plot.flextableGrob

plot a flextable grob
set_header_footer_df

Set flextable's header or footer rows
save_as_image

save a flextable as an image
save_as_html

Save a Flextable in an HTML File
save_as_docx

save flextable objects in an Word file
surround

Set borders for a selection of cells
tabulator

Tabulation of aggregations
style

Set flextable style
theme_alafoli

Apply alafoli theme
set_table_properties

Global table properties
set_header_labels

Change headers labels
summarizor

data summary preparation
theme_apa

Apply APA theme
shift_table

Create a shift table
tabulator_colnames

column keys of tabulator objects
theme_vanilla

Apply vanilla theme
theme_box

Apply box theme
theme_booktabs

Apply booktabs theme
theme_vader

Apply Sith Lord Darth Vader theme
width

Set columns width
vline

set vertical borders
vline_left

set flextable left vertical borders
theme_zebra

Apply zebra theme
valign

Set vertical alignment
vline_right

set flextable right vertical borders
use_model_printer

set model automatic printing as a flextable
use_df_printer

set data.frame automatic printing as a flextable
void

Delete flextable content
theme_tron

Apply tron theme
theme_tron_legacy

Apply tron legacy theme
add_header_row

Add header labels
add_footer_row

Add footer labels
add_header

Add column values as new lines in header
add_header_lines

Add labels as new rows in the header
align

Set text alignment
add_latex_dep

add latex dependencies
add_body_row

Add body labels