Skip to contents

Apply theme APA (the stylistic style of the American Psychological Association) to a flextable

Usage

theme_apa(x, ...)

Arguments

x

a flextable object

...

unused

behavior

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 additionnal header or footer rows).

If you want to automatically apply a theme function to each flextable, you can use the theme_fun argument of set_flextable_defaults(); be aware that this theme function is applied as the last instruction when calling 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 set_flextable_defaults() (or post_process_pdf, post_process_docx, post_process_pptx) to specify a theme to be applied systematically before the 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.

Examples

ft <- flextable(head(mtcars * 22.22))
ft <- theme_apa(ft)
ft

mpg

cyl

disp

hp

drat

wt

qsec

vs

am

gear

carb

466.62

133.32

3,555.20

2,444.20

86.66

58.22

365.74

0.00

22.22

88.88

88.88

466.62

133.32

3,555.20

2,444.20

86.66

63.88

378.18

0.00

22.22

88.88

88.88

506.62

88.88

2,399.76

2,066.46

85.55

51.55

413.51

22.22

22.22

88.88

22.22

475.51

133.32

5,732.76

2,444.20

68.44

71.44

431.96

22.22

0.00

66.66

22.22

415.51

177.76

7,999.20

3,888.50

69.99

76.44

378.18

0.00

0.00

66.66

44.44

402.18

133.32

4,999.50

2,333.10

61.33

76.88

449.29

22.22

0.00

66.66

22.22