Skip to contents

Apply theme AAGI to a flextable. An AAGI formatted table body is grey with a teal header and white header font. Header text is bold, text columns are left aligned, other columns are right aligned.

Usage

theme_ft_aagi(x)

Arguments

x

a flextable object

Value

a formatted flextable object

Behaviour

Theme functions are not like ggplot2 themes. They are applied to the existing table immediately. If you add a row in the footer, the new row is not formatted with the theme. The theme function applies the theme only to existing elements when the function is called.

That is why theme functions should be applied after all elements of the table have been added (mainly additional header or footer rows).

If you want to automatically apply a theme function to each flextable object, you can use the theme_fun argument of flextable::set_flextable_defaults(); be aware that this theme function is applied as the last instruction when calling flextable::flextable() – so if you add headers or footers to the array, they will not be formatted with the theme.

You can also use the post_process_html argument of flextable::set_flextable_defaults() (or post_process_pdf, post_process_docx, post_process_pptx) to specify a theme to be applied systematically before the flextable::flextable() is printed; in this case, don't forget to take care that the theme doesn't override any formatting done before the print statement.

See also

Other tables: theme_gt_aagi()

Examples

library(flextable)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
ft <- flextable(head(airquality) |> mutate(`Month Name` = "May"))
ft <- theme_ft_aagi(ft)
ft

Ozone

Solar.R

Wind

Temp

Month

Day

Month Name

41

190

7.4

67

5

1

May

36

118

8.0

72

5

2

May

12

149

12.6

74

5

3

May

18

313

11.5

62

5

4

May

14.3

56

5

5

May

28

14.9

66

5

6

May