Create a flextable object with function flextable.

flextable are designed to make tabular reporting easier for R users. Functions are available to let you format text, paragraphs and cells; table cells can be merge vertically or horizontally, row headers can easilly be defined, rows heights and columns widths can be manually set or automatically computed.

Default formatting properties are automatically applied to every flextable you produce. You can change these default values with function set_flextable_defaults().

flextable(
  data,
  col_keys = names(data),
  cwidth = 0.75,
  cheight = 0.25,
  defaults = list(),
  theme_fun = theme_booktabs
)

qflextable(data)

regulartable(data, col_keys = names(data), cwidth = 0.75, cheight = 0.25)

Arguments

data

dataset

col_keys

columns names/keys to display. If some column names are not in the dataset, they will be added as blank columns by default.

cwidth, cheight

initial width and height to use for cell sizes in inches.

defaults, theme_fun

deprecated, use set_flextable_defaults() instead.

Details

A flextable is made of 3 parts: header, body and footer.

Most functions have an argument named part that will be used to specify what part of of the table should be modified.

Note

Function regulartable is maintained for compatibility with old codes mades by users but be aware it produces the same exact object than flextable. This function should be deprecated then removed in the next versions.

Illustrations

qflextable

qflextable is a convenient tool to produce quickly a flextable for reporting where layoout is fixed and columns widths adjusted with autofit().

See also

Examples

ft <- flextable(head(mtcars)) ft
#> a flextable object. #> col_keys: `mpg`, `cyl`, `disp`, `hp`, `drat`, `wt`, `qsec`, `vs`, `am`, `gear`, `carb` #> header has 1 row(s) #> body has 6 row(s) #> original dataset sample: #> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 1 4 4 #> Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 1 4 4 #> Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 1 4 1 #> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1 #> Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 0 3 2