Minibars show up in docx print(preview=docx) but not in final knit_print() output

23 Views Asked by At

I'm using Quarto to produce some word doc reports and I'm struggling to get minibars to show up in a table in the final produced docx report. However, I can get the table to produce as expected when reviewing with print(preview="docx")

Here's an example of this problem with code and screenshots:

---
format: docx
---

{r}
#| label: my_test
#| tbl-cap: ""
#| echo: false
#| warning: false

library(flextable)
library(magrittr)
library(knitr)

ft <- flextable(head(iris, n = 10))

ft <- compose(ft,
    j = 1,
    value = as_paragraph(
        minibar(value = Sepal.Length, max = max(Sepal.Length))),
    part = "body"
)

ft %>% autofit() %>% 
    #knit_print()
    print(preview="docx")

Notice the last two lines. If I use knit_print() the word document doesn't include the minibars. If I use the print(preview="docx"), the bars show up in the temporary docx that is produced.

knitr_print output without minibars preview with minibars working

Any ideas what is causing this to happen?

Here's my sessionInfo():

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS 14.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/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] knitr_1.40      magrittr_2.0.3  flextable_0.9.4

loaded via a namespace (and not attached):
 [1] zip_2.3.1               Rcpp_1.0.9              fontBitstreamVera_0.1.1
 [4] pillar_1.9.0            compiler_4.2.2          later_1.3.1            
 [7] gfonts_0.2.0            tools_4.2.2             uuid_1.1-0             
[10] digest_0.6.30           jsonlite_1.8.3          evaluate_0.18          
[13] lifecycle_1.0.3         tibble_3.2.1            pkgconfig_2.0.3        
[16] rlang_1.1.3             shiny_1.8.0             cli_3.6.2              
[19] rstudioapi_0.14         curl_4.3.3              crul_1.3               
[22] yaml_2.3.6              fontLiberation_0.1.0    xfun_0.39              
[25] fastmap_1.1.1           xml2_1.3.3              officer_0.6.3          
[28] askpass_1.1             systemfonts_1.0.4       gdtools_0.3.5          
[31] vctrs_0.6.5             grid_4.2.2              glue_1.6.2             
[34] httpcode_0.3.0          data.table_1.14.4       R6_2.5.1               
[37] textshaping_0.3.7       fansi_1.0.3             rmarkdown_2.18         
[40] fontquiver_0.2.1        ellipsis_0.3.2          promises_1.2.0.1       
[43] htmltools_0.5.7         mime_0.12               xtable_1.8-4           
[46] httpuv_1.6.11           ragg_1.2.7              utf8_1.2.2             
[49] openssl_2.0.4           crayon_1.5.2
0

There are 0 best solutions below