Skip to contents

Adds a data frame as a flextable – in the current slide's content placeholder (pptx) or as a new table (docx).

Usage

report_add_table(doc, data, font_size = 12, autofit = TRUE)

Arguments

doc

A document from report_new().

data

A data frame / tibble.

font_size

Cell font size in points. Defaults to 12.

autofit

Word only: auto-size columns to content. Defaults to TRUE. On slides the table is always sized to fill the content placeholder.

Value

The updated document.

Details

On a slide the table is styled (a clean banded header, centred cells, a readable font) and its columns are widened to span the content placeholder – roughly in proportion to each column's contents – so it fills the slide meaningfully instead of sitting tiny in a corner. In Word it is added as a plain auto-fitted flextable.

Examples

tbl <- calc_percentage(podracing_survey, demo_gender)
doc <- report_new("docx") %>% report_add_table(tbl)
class(doc)
#> [1] "rdocx"