-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
transform-headers.Rmd
55 lines (41 loc) · 1.08 KB
/
transform-headers.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
title: "Create multi level headers"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Create multi level headers}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
This vignette introduces how to create multi level headers.
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
eval = "dplyr" %in% rownames(installed.packages())
)
```
```{r setup}
library(ftExtra)
```
# Prepare flextable
```{r}
ft <- iris[1:2, ] %>% flextable()
ft
```
# Split headers
The `split_header()` function generates multi-level headers by separating original headers (row names) by delimiters.
```{r}
ft %>% split_header()
```
The `sep` argument defines delimiters by regular expression.
The default delimiters are `.` and `_`.
Let's see what happens when `seop = "e"`
```{r}
ft %>% split_header(sep = "e")
```
# Span headers
The `span_header()` function also generates multi-level headers.
Unlike the `split_header()` function, the `span_header()` function merges adjacent headers if they have same values.
```{r}
ft %>% span_header()
```