rfortherestofus / omni

RMarkdown template, ggplot2 theme, and table function for OMNI Institute
https://rfortherestofus.github.io/omni/
Other
21 stars 4 forks source link

omni_table() or OMNI html report template knitting issue #85

Open OskaratOmni opened 4 months ago

OskaratOmni commented 4 months ago

Hey @dgkeyes I just sent you a video describing an issue we have been having when knitting tables with the omni_table() function.

image

You can see here that it does something weird where the lower part of the code chunk, the ```, displays and it messes up the figure caption too. Any ideas?

dgkeyes commented 4 months ago

Posting the video here for reference: https://muse.ai/e/4m6kV17

@OskaratOmni could you send me the code used to create this error? Or, better yet, could you create a simple, reproducible example that I can run to recreate this?

OskaratOmni commented 4 months ago

Hey @dgkeyes , you bet. I did find that using option = 'gt' made the issue go away.

Github doesn't allow attaching rmd files but here's the code:

---
title: "Odd omni table issue"
subtitle: "minimal working example"
author: "Oskar "
date: "`r Sys.Date()`"
output:
  omni::omni_html_report:
    hypothesis: false
editor_options: 
  chunk_output_type: console
  markdown: 
    wrap: 72
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.path='figs/',
                      echo=FALSE, # change to TRUE if most code chunks should knit to report 
                      warning=FALSE, 
                      message=FALSE)
library(tidyverse)
library(omni)
library(flextable)
mtcars %>% 
  slice(1:5) %>% 
  omni_table(caption = "Caption", option = "gt") 

Second table

mtcars %>% 
  slice(1:5) %>% 
  omni_table(caption = "Caption")
OskaratOmni commented 4 months ago

On my end the first table looks fine and the second has the weird table caption and stuff, like in the video. image

dgkeyes commented 4 months ago

Weird. This looks totally fine on my end.

image

I assume you've updated the omni package to the latest version?

Can you also run `sessionInfo()' in the console and paste in what you get? Here's what I get, for example:

R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.5

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: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] flextable_0.9.6 omni_1.0.2023   lubridate_1.9.3 forcats_1.0.0   stringr_1.5.1   dplyr_1.1.4    
 [7] purrr_1.0.2     readr_2.1.5     tidyr_1.3.1     tibble_3.2.1    ggplot2_3.5.1   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] gtable_0.3.5            xfun_0.44               ggrepel_0.9.5           tzdb_0.4.0             
 [5] vctrs_0.6.5             tools_4.3.3             generics_0.1.3          curl_5.2.1             
 [9] fansi_1.0.6             pkgconfig_2.0.3         data.table_1.15.4       uuid_1.2-0             
[13] gt_0.10.1               lifecycle_1.0.4         compiler_4.3.3          textshaping_0.4.0      
[17] munsell_0.5.1           httpuv_1.6.15           fontquiver_0.2.1        fontLiberation_0.1.0   
[21] htmltools_0.5.8.1       yaml_2.3.8              later_1.3.2             pillar_1.9.0           
[25] crayon_1.5.2            gfonts_0.2.0            openssl_2.2.0           rsconnect_1.2.0        
[29] mime_0.12               fontBitstreamVera_0.1.1 tidyselect_1.2.1        zip_2.3.1              
[33] digest_0.6.35           stringi_1.8.4           fastmap_1.2.0           grid_4.3.3             
[37] colorspace_2.1-0        cli_3.6.2               magrittr_2.0.3          crul_1.4.2             
[41] utf8_1.2.4              withr_3.0.0             gdtools_0.3.7           scales_1.3.0.9000      
[45] promises_1.3.0          timechange_0.3.0        rmarkdown_2.27          officer_0.6.6          
[49] ggtext_0.1.2            hms_1.1.3               askpass_1.2.0           ragg_1.3.2             
[53] shiny_1.8.1.1           evaluate_0.23           knitr_1.45              rlang_1.1.3            
[57] gridtext_0.1.5          Rcpp_1.0.12             xtable_1.8-4            glue_1.7.0             
[61] httpcode_0.3.0          xml2_1.3.6              rstudioapi_0.16.0       jsonlite_1.8.8         
[65] R6_2.5.1                systemfonts_1.1.0       fs_1.6.4               
OskaratOmni commented 3 months ago

Hey @dgkeyes Sorry for slow response. We are in peak reporting and I was out of office for a few days on top of that.

I just did a bunch of updating hoping it would resolve the issue but I'm still getting it on my end.

Here's my session info:

sessionInfo() R version 4.4.0 (2024-04-24 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/Denver tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] flextable_0.9.6 omni_1.0.2023 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
[8] readr_2.1.5 tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0

loaded via a namespace (and not attached): [1] gtable_0.3.5 xfun_0.44 ggrepel_0.9.5 tzdb_0.4.0
[5] vctrs_0.6.5 tools_4.4.0 generics_0.1.3 curl_5.2.1
[9] fansi_1.0.6 pkgconfig_2.0.3 data.table_1.15.4 gt_0.10.1
[13] uuid_1.2-0 lifecycle_1.0.4 farver_2.1.2 compiler_4.4.0
[17] textshaping_0.4.0 munsell_0.5.1 httpuv_1.6.15 fontquiver_0.2.1
[21] fontLiberation_0.1.0 sass_0.4.9 htmltools_0.5.8.1 yaml_2.3.8
[25] pillar_1.9.0 later_1.3.2 crayon_1.5.2 gfonts_0.2.0
[29] openssl_2.2.0 mime_0.12 fontBitstreamVera_0.1.1 tidyselect_1.2.1
[33] zip_2.3.1 digest_0.6.35 stringi_1.8.4 labeling_0.4.3
[37] fastmap_1.2.0 grid_4.4.0 colorspace_2.1-0 cli_3.6.2
[41] magrittr_2.0.3 crul_1.4.2 utf8_1.2.4 withr_3.0.0
[45] gdtools_0.3.7 scales_1.3.0 promises_1.3.0 timechange_0.3.0
[49] rmarkdown_2.27 officer_0.6.6 ggtext_0.1.2 askpass_1.2.0
[53] ragg_1.3.2 hms_1.1.3 evaluate_0.24.0 shiny_1.8.1.1
[57] knitr_1.47 rlang_1.1.4 gridtext_0.1.5 Rcpp_1.0.12
[61] xtable_1.8-4 glue_1.7.0 httpcode_0.3.0 xml2_1.3.6
[65] rstudioapi_0.16.0 jsonlite_1.8.8 R6_2.5.1 fs_1.6.4
[69] systemfonts_1.1.0

Restarting R session...

tvroylandt commented 3 months ago

Would you try to install the dev version of flextable with devtools::install_github("davidgohel/flextable") (according to https://github.com/davidgohel/flextable/issues/621 this is supposed to work, even if on my side this doesn't).

If you remove the caption this works, it's a matter of knitr blocks that changed

OskaratOmni commented 3 months ago

Thanks @tvroylandt , I tried this and verified that the dev version installed. It didn't work on my end either. We still get the `{=html}` characters in both pdf and html with flextable.

@tvroylandt are you getting these too? @dgkeyes does not get them but we weren't able to identify a difference in our setups that could be behind the difference in behavior.

tvroylandt commented 3 months ago

I have them too bur wasn't able yet to solve that