as_flextable.grouped_data: Transform a 'grouped_data' object into a flextable

View source: R/as_flextable.R

as_flextable.grouped_dataR Documentation

Transform a 'grouped_data' object into a flextable

Description

Produce a flextable from a table produced by function as_grouped_data().

Usage

## S3 method for class 'grouped_data'
as_flextable(x, col_keys = NULL, hide_grouplabel = FALSE, ...)

Arguments

x

'grouped_data' object to be transformed into a "flextable"

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.

hide_grouplabel

if TRUE, group label will not be rendered, only level/value will be rendered.

...

unused argument

See Also

as_grouped_data()

Other as_flextable methods: as_flextable.data.frame(), as_flextable.gam(), as_flextable.glm(), as_flextable.htest(), as_flextable.kmeans(), as_flextable.lm(), as_flextable.merMod(), as_flextable.pam(), as_flextable.summarizor(), as_flextable.table(), as_flextable.tabular(), as_flextable.tabulator(), as_flextable.xtable(), as_flextable()

Examples

library(data.table)
CO2 <- CO2
setDT(CO2)
CO2$conc <- as.integer(CO2$conc)

data_co2 <- dcast(CO2, Treatment + conc ~ Type,
  value.var = "uptake", fun.aggregate = mean
)
data_co2 <- as_grouped_data(x = data_co2, groups = c("Treatment"))

ft <- as_flextable(data_co2)
ft <- add_footer_lines(ft, "dataset CO2 has been used for this flextable")
ft <- add_header_lines(ft, "mean of carbon dioxide uptake in grass plants")
ft <- set_header_labels(ft, conc = "Concentration")
ft <- autofit(ft)
ft <- width(ft, width = c(1, 1, 1))
ft

flextable documentation built on Oct. 23, 2023, 1:07 a.m.