davidgohel / ReporteRs

Note that ReporteRs has been removed from CRAN the 16th of July 2018 and is not maintained anymore. please migrate to officer.
245 stars 44 forks source link

addPlot function freezing RStudio #181

Closed gary-wagner closed 7 years ago

gary-wagner commented 7 years ago

First of all, thank you. I have used the package for some time with great success. However, just recently I can no longer add plots using the 'addPlot' function because Rstudio will freeze.

Even using the simple example below, RStudio will hang (I've never let it go longer than 15 minutes) on the addPlot line.

library(ReporteRs) library(ggplot2) mydoc <- pptx( title = "title" ) mydoc <- addSlide( mydoc, slide.layout = "Title and Content" ) myplot <- qplot(Sepal.Length, Petal.Length, data = iris, color = Species, size = Petal.Width) mydoc <- addPlot(doc = mydoc, fun = print, x = myplot, offx = 1, offy = 1, width = 6, height = 5)

So far, I have reinstalled rJava, ReporteRs, and explicitly set the JAVA_HOME path all with no luck. Here is my session info: R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

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

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

other attached packages: [1] magrittr_1.5 ggplot2_2.2.1 ReporteRs_0.8.8 ReporteRsjars_0.0.2 httr_1.2.1

loaded via a namespace (and not attached): [1] Rcpp_0.12.9 knitr_1.15.1 xml2_1.1.1 munsell_0.4.3 xtable_1.8-2 colorspace_1.2-6 R6_2.1.3 plyr_1.8.4
[9] dplyr_0.5.0 tools_3.3.1 grid_3.3.1 gtable_0.2.0 png_0.1-7 rvg_0.1.3 R.oo_1.20.0 DBI_0.5-1
[17] htmltools_0.3.5 lazyeval_0.2.0 digest_0.6.12 assertthat_0.1 tibble_1.2 shiny_1.0.0 rJava_0.9-8 officer_0.1.1
[25] purrr_0.2.2 base64enc_0.1-3 R.utils_2.5.0 mime_0.5 labeling_0.3 gdtools_0.1.3 scales_0.4.1 R.methodsS3_1.7.1 [33] httpuv_1.3.3

Any thoughts?

davidgohel commented 7 years ago

Hi,

I have not been able to reproduce the issue (same config than yours but on win 10).

I am not sure it is a crash, it may be because gdtools (the package used to compute font metrics) is creating (only once) a font cache from your settings. Could you wait until the process has ended or crashed?

gary-wagner commented 7 years ago

I set it to run overnight and timed the process. It did work, but it took 21 minutes to run the simple example.

Based on your comment, I re-installed gdtools and everything seems to be working fine. Thank you very much!

Your new officer package looks nice as well. Any plans to add something like addPlot so that vector graphics can be written to PPTX?

On Fri, Mar 17, 2017 at 4:48 AM, David Gohel notifications@github.com wrote:

Hi,

I have not been able to reproduce the issue (same config than yours but on win 10).

I am not sure it is a crash, it may be because gdtools (the package used to compute font metrics) is creating (only once) a font cache from your settings. Could you wait for the process to end?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davidgohel/ReporteRs/issues/181#issuecomment-287299016, or mute the thread https://github.com/notifications/unsubscribe-auth/AXOpWku5l6GX5YqrFoqlOlfP3W-bcdvWks5rmkjdgaJpZM4Mf6A8 .

davidgohel commented 7 years ago

Thanks for the feedback (gdtools did built a font cache but it only do it once... )

Yes, use rvg (documentation will be improved in the following weeks):

library(rvg)
library(officer)

doc <- read_pptx()
doc <- add_slide(doc, layout = "Title and Content", master = "Office Theme")
doc <- ph_with_vg(doc, code = barplot(1:10), type = "body")
print(doc, target = "my_plot.pptx")

David