flextable
flextable copied to clipboard
Unable to specify a border partially across merged columns in header, even with fix_border_issues()
I'm encountering a border + merging issue that doesn't seem to be addressed by current tools. Reprex below
(Reprex's simplicity will make this seem silly from a design perspective, but in my actual use case I could use functionality like this to fit in the broader design. Also of course it's just not giving back what's specified.)
Thanks for such a versatile package!
require(flextable) # 0.7.0
#> Loading required package: flextable
require(tidyverse)
#> Loading required package: tidyverse
basetabl <-
iris %>%
slice(1:5) %>%
flextable() %>%
set_header_labels(Sepal.Width = "") %>%
border_remove() %>%
# Merge two cells:
merge_at(i = 1, j = 1:2, part = "header")
basetabl %>%
# None of these work to produce a horizontal
# line centered on column 2:
hline_top(j = 2, part = "header") %>%
hline_bottom(j = 2, part = "header") %>%
hline_top(j = 2, part = "body") %>%
# This does not help:
fix_border_issues()
basetabl %>%
# Similarly can not incorporate into longer line:
hline_bottom(j = 2:5, part = "header") %>%
fix_border_issues()
basetabl %>%
# This "works", but adds borders across both columns 1 & 2
# despite 1 & 2 not being merged in the body:
hline_top(j = 1, part = "body") %>%
fix_border_issues()
sessionInfo()
#> R version 4.2.0 (2022-04-22)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur/Monterey 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] forcats_0.5.1 stringr_1.4.0 dplyr_1.0.9 purrr_0.3.4
#> [5] readr_2.1.2 tidyr_1.2.0 tibble_3.1.6 ggplot2_3.3.5
#> [9] tidyverse_1.3.1 flextable_0.7.0
#>
#> loaded via a namespace (and not attached):
#> [1] tidyselect_1.1.2 xfun_0.30 haven_2.5.0 colorspace_2.0-3
#> [5] vctrs_0.4.1 generics_0.1.2 htmltools_0.5.2 yaml_2.3.5
#> [9] base64enc_0.1-3 utf8_1.2.2 rlang_1.0.2 pillar_1.7.0
#> [13] glue_1.6.2 withr_2.5.0 DBI_1.1.2 gdtools_0.2.4
#> [17] dbplyr_2.1.1 readxl_1.4.0 modelr_0.1.8 uuid_1.1-0
#> [21] lifecycle_1.0.1 cellranger_1.1.0 munsell_0.5.0 gtable_0.3.0
#> [25] rvest_1.0.2 zip_2.2.0 evaluate_0.15 knitr_1.39
#> [29] tzdb_0.3.0 fastmap_1.1.0 fansi_1.0.3 highr_0.9
#> [33] broom_0.8.0 Rcpp_1.0.8.3 backports_1.4.1 scales_1.2.0
#> [37] jsonlite_1.8.0 systemfonts_1.0.4 fs_1.5.2 hms_1.1.1
#> [41] digest_0.6.29 stringi_1.7.6 grid_4.2.0 cli_3.3.0
#> [45] tools_4.2.0 magrittr_2.0.3 crayon_1.5.1 pkgconfig_2.0.3
#> [49] ellipsis_0.3.2 data.table_1.14.2 xml2_1.3.3 lubridate_1.8.0
#> [53] reprex_2.0.1 httr_1.4.2 assertthat_0.2.1 rmarkdown_2.14
#> [57] officer_0.4.2 rstudioapi_0.13 R6_2.5.1 compiler_4.2.0
Created on 2022-05-16 by the reprex package (v2.0.1)