davidgohel / rvg

https://davidgohel.github.io/rvg/
132 stars 15 forks source link

Getting error with ggplot2 when exporting to pptx #53

Closed davidgohel closed 1 year ago

davidgohel commented 1 year ago

Discussed in https://github.com/davidgohel/officer/discussions/491

Originally posted by **schuettl** April 14, 2023 Hi there, thanks for the development of this supercool package! I got stuck on a strange error, I am not sure if it's a bug, or if it's me... My example: ``` library("officer") library("ggplot2") library("tidyverse") p1 <- ggplot(tibble(x=1,y=2,z=4))+geom_point(aes(x=x,y=y)) p_dml <- rvg::dml(ggobj = p1) officer::read_pptx() %>% officer::add_slide() %>% officer::ph_with(p_dml, officer::ph_location()) %>% base::print( target = here::here( "test", "test.pptx" ) ) ``` works completely fine, but ``` p2 <- ggplot(tibble(x=1,y=2,z=4))+geom_point(aes(x=x,y=y,color=z)) p_dml <- rvg::dml(ggobj = p2) officer::read_pptx() %>% officer::add_slide() %>% officer::ph_with(p_dml, officer::ph_location()) %>% base::print( target = here::here( "test", "test.pptx" ) ) ``` throws the error: ``` Error in open.connection(con, "rb") : cannot open the connection In addition: Warning message: In open.connection(con, "rb") : cannot open file '/tmp/RtmpKOBSCr/file27df431cbcd516/raster-rId000002.png': No such file or directory` ``` Am I doing something wrong here? Thanks for your help! ``` 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/blas/libblas.so.3.9.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 locale: [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8 LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8 [7] LC_PAPER=C.UTF-8 LC_NAME=C 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] gdtools_0.3.3 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.1 purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 [10] tidyverse_2.0.0 ggplot2_3.4.2 officer_0.6.2 loaded via a namespace (and not attached): [1] uuid_1.1-0 backports_1.4.1 systemfonts_1.0.4 plyr_1.8.8 igraph_1.4.0 [6] splines_4.2.3 BiocParallel_1.32.5 GenomeInfoDb_1.34.9 digest_0.6.31 foreach_1.5.2 [11] htmltools_0.5.4 fansi_1.0.4 magrittr_2.0.3 cluster_2.1.4 tzdb_0.3.0 [16] openxlsx_4.2.5.2 Biostrings_2.66.0 matrixStats_0.63.0 RcppParallel_5.1.6 timechange_0.2.0 [21] askpass_1.1 gfonts_0.2.0 jpeg_0.1-10 colorspace_2.1-0 ggrepel_0.9.3 [26] textshaping_0.3.6 xfun_0.37 crayon_1.5.2 RCurl_1.98-1.12 jsonlite_1.8.4 [31] dada2_1.26.0 survival_3.5-3 iterators_1.0.14 ape_5.7-1 glue_1.6.2 [36] rvg_0.3.2 gtable_0.3.1 zlibbioc_1.44.0 XVector_0.38.0 DelayedArray_0.24.0 [41] scico_1.3.1 phyloseq_1.42.0 car_3.1-1 Rhdf5lib_1.20.0 BiocGenerics_0.44.0 [46] abind_1.4-5 scales_1.2.1 fontquiver_0.2.1 pheatmap_1.0.12 rstatix_0.7.2 [51] Rcpp_1.0.10 xtable_1.8-4 stats4_4.2.3 fontLiberation_0.1.0 htmlwidgets_1.6.1 [56] RColorBrewer_1.1-3 ellipsis_0.3.2 farver_2.1.1 pkgconfig_2.0.3 deldir_1.0-6 [61] utf8_1.2.3 here_1.0.1 crul_1.3 labeling_0.4.2 tidyselect_1.2.0 [66] rlang_1.1.0 reshape2_1.4.4 later_1.3.0 munsell_0.5.0 tools_4.2.3 [71] cli_3.6.1 generics_0.1.3 devEMF_4.3 ade4_1.7-22 export_0.3.0 [76] broom_1.0.3 evaluate_0.20 biomformat_1.26.0 fastmap_1.1.0 ragg_1.2.5 [81] knitr_1.42 zip_2.2.2 rgl_1.1.3 nlme_3.1-162 mime_0.12 [86] xml2_1.3.3 compiler_4.2.3 rstudioapi_0.14 png_0.1-8 curl_5.0.0 [91] ggsignif_0.6.4 stringi_1.7.12 stargazer_5.2.3 lattice_0.20-45 Matrix_1.5-1 [96] fontBitstreamVera_0.1.1 vegan_2.6-4 microbiome_1.20.0 permute_0.9-7 multtest_2.54.0 [101] vctrs_0.6.1 microbiomeutilities_1.00.17 pillar_1.8.1 lifecycle_1.0.3 rhdf5filters_1.10.0 [106] microViz_0.10.7 data.table_1.14.8 cowplot_1.1.1 bitops_1.0-7 flextable_0.9.1 [111] GenomicRanges_1.50.2 httpuv_1.6.9 latticeExtra_0.6-30 hwriter_1.3.2.1 R6_2.5.1 [116] ShortRead_1.56.1 promises_1.2.0.1 renv_0.16.0 IRanges_2.32.0 writexl_1.4.2 [121] sessioninfo_1.2.2 codetools_0.2-19 MASS_7.3-58.2 SummarizedExperiment_1.28.0 rhdf5_2.42.1 [126] openssl_2.0.5 rprojroot_2.0.3 withr_2.5.0 httpcode_0.3.0 Rsamtools_2.14.0 [131] GenomicAlignments_1.34.0 S4Vectors_0.36.1 GenomeInfoDbData_1.2.9 mgcv_1.8-41 parallel_4.2.3 [136] hms_1.1.2 grid_4.2.3 gghalves_0.1.4 rmarkdown_2.20 MatrixGenerics_1.10.0 [141] carData_3.0-5 microshades_1.10 Rtsne_0.16 ggpubr_0.6.0 Biobase_2.58.0 [146] shiny_1.7.4 base64enc_0.1-3 interp_1.1-3 ``` `