Merck / r2rtf

Easily Create Production-Ready Rich Text Format (RTF) Table and Figure
https://merck.github.io/r2rtf
GNU General Public License v3.0
76 stars 19 forks source link

`assemble_rtf` error/warning message #176

Closed kaz462 closed 1 year ago

kaz462 commented 1 year ago

Question I'm not able to repeat this file: tlf-primary.rtf in the output by using r2rtf::assemble_rtf. I tried with tlf-efficacy.rtf and it works fine.

Could you help me understand the error/warning message? Thanks a lot!

To reproduce

tlf_path <- rep(
  "/cloud/project/submission/output/tlf-primary-pilot3.rtf", # primary table
  2 
)

r2rtf::assemble_rtf(
  input = tlf_path,
  output = "rtf-combine.rtf"
)
#> Warning in FUN(X[[i]], ...): incomplete final line found on
#> '/cloud/project/submission/output/tlf-primary-pilot3.rtf'

#> Warning in FUN(X[[i]], ...): incomplete final line found on
#> '/cloud/project/submission/output/tlf-primary-pilot3.rtf'
#> Warning in max(grep("fcharset", rtf[[1]])): no non-missing arguments to max;
#> returning -Inf
#> Error in start[i]:end[i]: result would be too long a vector

Created on 2023-06-16 with reprex v2.0.2

Session info

> sessionInfo()
R version 4.2.3 (2023-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8        LC_COLLATE=C.UTF-8    
 [5] LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8    LC_PAPER=C.UTF-8       LC_NAME=C             
 [9] LC_ADDRESS=C           LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

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

other attached packages:
[1] reprex_2.0.2    r2rtf_1.0.1     pilot3_0.1.1    pharmaRTF_0.1.4 Tplyr_1.1.0     dplyr_1.1.0    
[7] tidyr_1.3.0    

loaded via a namespace (and not attached):
 [1] styler_1.9.1        envsetup_0.0.1.9000 tidyselect_1.2.0    xfun_0.37           purrr_1.0.1        
 [6] haven_2.5.2         vctrs_0.5.2         generics_0.1.3      usethis_2.1.6       htmltools_0.5.4    
[11] yaml_2.3.7          utf8_1.2.3          rlang_1.1.0         R.oo_1.25.0         huxtable_5.5.2     
[16] pillar_1.8.1        glue_1.6.2          withr_2.5.0         R.utils_2.12.2      emmeans_1.8.5      
[21] lifecycle_1.0.3     R.cache_0.16.0      stringr_1.5.0       R.methodsS3_1.8.2   mvtnorm_1.1-3      
[26] evaluate_0.20       knitr_1.42          forcats_1.0.0       tzdb_0.3.0          callr_3.7.3        
[31] fastmap_1.1.1       ps_1.7.2            fansi_1.0.4         xtable_1.8-4        readr_2.1.4        
[36] renv_0.17.0         config_0.3.1        fs_1.6.1            hms_1.1.2           digest_0.6.31      
[41] stringi_1.7.12      processx_3.8.0      cli_3.6.0           tools_4.2.3         magrittr_2.0.3     
[46] tibble_3.2.0        crayon_1.5.2        pkgconfig_2.0.3     ellipsis_0.3.2      estimability_1.4.1 
[51] assertthat_0.2.1    rmarkdown_2.20      rstudioapi_0.14     R6_2.5.1            compiler_4.2.3 
elong0527 commented 1 year ago

r2rtf::assemble only work for RTF files generated by the r2rtf package.

From the source code , you can see tlf-primary.rtf is created by the pharmaRTF package.

https://github.com/RConsortium/submissions-pilot1/blob/main/vignettes/tlf-primary.Rmd

If you want to assemble RTF files generated beyond r2rtf package, assemble_docx is a more robust solution.

https://r4csr.org/tlf-assemble.html

kaz462 commented 1 year ago

Thanks @elong0527 ! This is good to know for someone new to this package :) Is the following documented somewhere?

r2rtf::assemble only work for RTF files generated by the r2rtf package.

If you want to assemble RTF files generated beyond r2rtf package, assemble_docx is a more robust solution.

elong0527 commented 1 year ago

This issue will be the reference for future people. :)