library(flextable)
We will first define two types of borders, the first will be used for the outer borders and the second will be used for the inner borders.
big_border = fp_border_default(color="red", width = 2)
small_border = fp_border_default(color="gray", width = 1)
To be sure there is no borders when starting, you can
use function border_remove()
.
ft <- flextable(head(airquality))
ft <- border_remove(x = ft)
ft
Ozone | Solar.R | Wind | Temp | Month | Day |
41 | 190 | 7.4 | 67 | 5 | 1 |
36 | 118 | 8.0 | 72 | 5 | 2 |
12 | 149 | 12.6 | 74 | 5 | 3 |
18 | 313 | 11.5 | 62 | 5 | 4 |
14.3 | 56 | 5 | 5 | ||
28 | 14.9 | 66 | 5 | 6 |
Now let’s apply outer and inner borders with functions border_outer()
,
border_inner_v()
and border_inner_h()
.
ft <- border_inner_h(ft, part="all", border = small_border )
ft <- border_inner_v(ft, part="all", border = small_border )
ft <- border_outer(ft, part="all", border = big_border )
ft
Ozone | Solar.R | Wind | Temp | Month | Day |
41 | 190 | 7.4 | 67 | 5 | 1 |
36 | 118 | 8.0 | 72 | 5 | 2 |
12 | 149 | 12.6 | 74 | 5 | 3 |
18 | 313 | 11.5 | 62 | 5 | 4 |
14.3 | 56 | 5 | 5 | ||
28 | 14.9 | 66 | 5 | 6 |