fix_border_issues() does not work correctly with merge_v() and hline()
padpadpadpad opened this issue · 2 comments
padpadpadpad commented
Hi everyone
I am trying to merge a column and then create horizontal lines that split each level of the factor. When I merge the first column, the horizontal line works for printing of the table, but it does not work for the plotting, which is then used in save_as_image()
from what I can tell. Seems to be an error but cannot work out where or how to fix it.
Below is reproducible code I took from fix_border_issues()
and amended slightly.
library(officer)
library(flextable)
dat <- data.frame(a = c(1,1,2,2,5), b = 6:10)
ft <- flextable(dat)
ft <- merge_v(ft, ~a, part = "body")
ft <- hline(ft,
i = 2, part = "body",
border = fp_border(color = "red")
)
print(ft)
plot(ft)
ft <- fix_border_issues(ft)
print(ft)
plot(ft)
ft <- hline(ft,
i = c(1, 2), j =1, part = "body",
border = fp_border(color = "red")
)
plot(ft)
Session Info:
R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.1.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/London
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] officer_0.6.4 patchwork_1.1.3 flextable_0.9.4 lubridate_1.9.3 forcats_1.0.0
[6] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.4 tidyr_1.3.0
[11] tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0 secsse_3.0.2
loaded via a namespace (and not attached):
[1] gtable_0.3.4 xfun_0.41 lattice_0.22-5
[4] tzdb_0.4.0 vctrs_0.6.5 tools_4.3.2
[7] generics_0.1.3 stats4_4.3.2 curl_5.1.0
[10] fansi_1.0.5 pkgconfig_2.0.3 Matrix_1.6-3
[13] data.table_1.14.8 RColorBrewer_1.1-3 MuMIn_1.47.5
[16] uuid_1.1-1 RcppParallel_5.1.7 lifecycle_1.0.4
[19] farver_2.1.1 compiler_4.3.2 textshaping_0.3.7
[22] munsell_0.5.0 httpuv_1.6.12 fontquiver_0.2.1
[25] fontLiberation_0.1.0 htmltools_0.5.7 yaml_2.3.7
[28] pillar_1.9.0 later_1.3.1 crayon_1.5.2
[31] gfonts_0.2.0 ellipsis_0.3.2 openssl_2.1.1
[34] nlme_3.1-163 mime_0.12 fontBitstreamVera_0.1.1
[37] zip_2.3.0 tidyselect_1.2.0 digest_0.6.33
[40] stringi_1.8.3 labeling_0.4.3 fastmap_1.1.1
[43] grid_4.3.2 colorspace_2.1-0 cli_3.6.2
[46] magrittr_2.0.3 librarian_1.8.1 crul_1.4.0
[49] utf8_1.2.4 withr_2.5.2 gdtools_0.3.4
[52] scales_1.2.1 promises_1.2.1 timechange_0.2.0
[55] rmarkdown_2.25 ragg_1.2.6 askpass_1.2.0
[58] hms_1.1.3 evaluate_0.23 shiny_1.8.0
[61] knitr_1.45 rlang_1.1.2 Rcpp_1.0.11
[64] xtable_1.8-4 glue_1.6.2 httpcode_0.3.0
[67] xml2_1.3.5 pkgload_1.3.3 rstudioapi_0.15.0
[70] jsonlite_1.8.8 R6_2.5.1 systemfonts_1.0.5
davidgohel commented
thanks, it should be fixed now
dat <- data.frame(a = c(1, 1, 2, 2, 5), b = 6:10)
ft <- flextable(dat)
ft <- merge_v(ft, ~a, part = "body")
ft <- hline(
x = ft,
i = 2, part = "body",
border = fp_border(color = "red")
)
path <- save_as_image(ft, path = tempfile(fileext = ".png"), res = 150)
browseURL(path)
github-actions commented
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.