A flextable theme for ivo_table objects.
Usage
ivo_flextable_theme(
x,
kway = 2,
rowsums = FALSE,
caption = NA,
highlight_cols = NULL,
highlight_rows = NULL,
color = "darkgreen",
font_name = "Arial",
bold_cols = NULL
)
Arguments
- x
A flextable.
- kway
The number of "horizontal" variables in the table.
- rowsums
A logical, saying whether the rightmost column in the table contains the sum of each row. Defaults to FALSE.
- caption
An optional string containing a table caption.
- highlight_cols
A numeric vector containing the indices of the columns that should be highlighted.
- highlight_rows
A numeric vector containing the indices of the rows that should be highlighted.
- color
A named color or a color HEX code, used for the lines in the table. Defaults to "darkgreen".
- font_name
The name of the font to be used in the table. Defaults to "Arial".
- bold_cols
A numeric vector containing the indices of the columns that should use a bold font.
Examples
library(tidyr)
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
library(flextable)
example_data <- data.frame(Year = sample(2020:2023, 50, replace = TRUE),
A = sample(c("Type 1", "Type 2"), 50, replace = TRUE),
B = sample(c("Apples", "Oranges", "Bananas"), 50, replace = TRUE),
C = sample(c("Swedish", "Norwegian", "Chilean"), 50, replace = TRUE))
example_data |> select(B, A) |>
ftable(exclude=NULL) |>
data.frame() |>
spread(A, Freq) |>
regulartable() |>
ivo_flextable_theme()
B
Type 1
Type 2
Apples
11
10
Bananas
6
9
Oranges
5
9