flextable | R Documentation |
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 easily
be defined, rows heights and columns widths can be manually set or automatically
computed.
If working with 'R Markdown' documents, you should read about knitr
chunk options in knit_print.flextable()
and about setting
default values with set_flextable_defaults()
.
flextable(
data,
col_keys = names(data),
cwidth = 0.75,
cheight = 0.25,
defaults = list(),
theme_fun = theme_booktabs,
use_labels = TRUE
)
qflextable(data)
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 |
use_labels |
Logical; if TRUE, any column labels or value labels present in the dataset will be used for display purposes. Defaults to TRUE. |
Some default formatting properties are automatically applied to every flextable you produce.
It is highly recommended to use this function because
its use will minimize the code. For example, instead of
calling the fontsize()
function over and over again for
each new flextable, set the font size default value by
calling (before creating the flextables)
set_flextable_defaults(font.size = 11)
. This is also
a simple way to have homogeneous arrays and make the
documents containing them easier to read.
You can change these default values with function
set_flextable_defaults()
. You can reset them
with function init_flextable_defaults()
. You
can access these values by calling get_flextable_defaults()
.
The 'flextable' package will translate for you
the new lines expressed in the form \n
and
the tabs expressed in the form \t
.
The new lines will be transformed into "soft-return", that is to say a simple carriage return and not a new paragraph.
Tabs are different depending on the output format:
HTML is using entity em space
Word - a Word 'tab' element
PowerPoint - a PowerPoint 'tab' element
latex - tag "\quad "
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.
qflextable
is a convenient tool to produce quickly
a flextable for reporting where layout is fixed (see
set_table_properties()
) and columns
widths are adjusted with autofit()
.
style()
, autofit()
, theme_booktabs()
, knit_print.flextable()
,
compose()
, footnote()
, set_caption()
ft <- flextable(head(mtcars))
ft
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.