Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

df_printer

Summarize a data.frame as a flextable


Description

Create a summary from a data.frame as a flextable. This function is to be used in an R Markdown document.

To use that function, you must declare it in the part df_print of the 'YAML' header of your R Markdown document:

---
df_print: !expr function(x) flextable::df_printer(x)
---

We notice an unexpected behavior with bookdown. When using bookdown it is necessary to use use_df_printer() instead in a setup run chunk:

use_df_printer()

Usage

df_printer(dat, ...)

Arguments

dat

the data.frame

...

unused argument

Details

'knitr' chunk options are available to customize the output:

  • ft_max_row: The number of rows to print. Default to 10.

  • ft_split_colnames: Should the column names be split (with non alpha-numeric characters). Default to FALSE.

  • ft_short_strings: Should the character column be shorten. Default to FALSE.

  • ft_short_size: Maximum length of character column if ft_short_strings is TRUE. Default to 35.

  • ft_short_suffix: Suffix to add when character values are shorten. Default to "...".

  • ft_do_autofit: Use autofit() before rendering the table. Default to TRUE.

  • ft_show_coltype: Show column types. Default to TRUE.

  • ft_color_coltype: Color to use for column types. Default to "#999999".

See Also

Examples

df_printer(head(mtcars))

flextable

Functions for Tabular Reporting

v0.6.10
GPL-3
Authors
David Gohel [aut, cre], Clementine Jager [ctb], Quentin Fazilleau [ctb], Maxim Nazarov [ctb] (rmarkdown for docx output), Titouan Robert [ctb], Michael Barrowman [ctb] (inline footnotes), Atsushi Yasumoto [ctb] (support for bookdown cross reference), Paul Julian [ctb] (support for gam objects)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.