Span the header based on delimiters

span_header(x, sep = "[_\\.]", theme_fun = NULL, ...)

Arguments

x

A flextable object`

sep

Separator between columns.

If character, sep is interpreted as a regular expression. The default value is a regular expression that matches any sequence of non-alphanumeric values.

If numeric, sep is interpreted as character positions to split at. Positive values start at 1 at the far-left of the string; negative value start at -1 at the far-right of the string. The length of sep should be one less than into.

theme_fun

A flextable theme function. When NULL (default), the value is resolved by flextable::get_flextable_defaults().

...

Passed to theme_fun

Examples

iris %>%
  as_flextable() %>%
  span_header()
#> a flextable object.
#> col_keys: `Sepal.Length`, `Sepal.Width`, `Petal.Length`, `Petal.Width`, `Species` 
#> header has 2 row(s) 
#> body has 150 row(s) 
#> original dataset sample: 
#>   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1          5.1         3.5          1.4         0.2  setosa
#> 2          4.9         3.0          1.4         0.2  setosa
#> 3          4.7         3.2          1.3         0.2  setosa
#> 4          4.6         3.1          1.5         0.2  setosa
#> 5          5.0         3.6          1.4         0.2  setosa