0

I appear to be getting an error that causes RStudio to crash when trying to use the rvg options to plot ggplots to a slide when using officer.

The documentation suggests something similar should work:

https://davidgohel.github.io/officer/articles/offcran/graphics.html#vector-graphics

Below is the code I am using:

require(ggplot2)
require(rvg)
require(officer)
doc <- read_pptx()
doc <- add_slide(doc, "Title and Content", "Office Theme")
mm <-ggplot(mtcars,aes(x=cyl))+geom_bar(stat='count')
#doc <- rvg::ph_with_vg_at(x=doc, ggobj=mm,left = 1, top = 2, width = 6, height = 4) # This automatically causes R to exit....
value = dml(ggobj=mm) # This works....
loc_data <- ph_location(left = 1, top = 2, width = 6, height = 4) # this works too....
doc <- officer::ph_with(doc, value, location = loc_data) #...this line does NOT work....
#doc <- officer::ph_with(doc, value, location = ph_location_type(type = "body")) #...this line does not work....
#doc <- officer::ph_with(doc, value, location = ph_location(left = 1, top = 2, width = 6, height = 4)) #...this line does not work either....
print(doc, target = "test_output.pptx") 

The below is my session Info:

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252
[2] LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

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

other attached packages:
[1] officer_0.3.5 rvg_0.2.1     ggplot2_3.2.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2        xml2_1.2.2        magrittr_1.5      uuid_0.1-2
 [5] tidyselect_0.2.5  munsell_0.5.0     colorspace_1.4-1  R6_2.4.0
 [9] rlang_0.4.1       dplyr_0.8.3       grid_3.6.1        gtable_0.3.0
[13] withr_2.1.2       htmltools_0.4.0   systemfonts_0.1.1 lazyeval_0.2.2
[17] assertthat_0.2.1  digest_0.6.20     tibble_2.1.3      crayon_1.3.4
[21] zip_2.0.4         purrr_0.3.3       base64enc_0.1-3   vctrs_0.2.0
[25] zeallot_0.1.0     glue_1.3.1        compiler_3.6.1    pillar_1.4.0
[29] gdtools_0.2.1     scales_1.0.0      backports_1.1.5   pkgconfig_2.0.2

I having broken down the original issue I now get the following errror message:

Error: `.call` must be a quoted call
Call `rlang::last_error()` to see a backtrace.
> rlang::last_error()
<error/rlang_error>
`.call` must be a quoted call
Backtrace:
 1. officer::ph_with(doc, value, location = loc_data)
 2. rvg:::ph_with.dml(doc, value, location = loc_data)
 3. officer::location_eval(args$location, x)
 4. rlang::call_modify(...)
 5. rlang:::abort_call_input_type(".call")
Call `rlang::last_trace()` to see the full backtrace.
> rlang::last_trace()
<error/rlang_error>
`.call` must be a quoted call
Backtrace:
    x
 1. +-officer::ph_with(doc, value, location = loc_data)
 2. \-rvg:::ph_with.dml(doc, value, location = loc_data)
 3.   \-officer::location_eval(args$location, x)
 4.     \-rlang::call_modify(...)
 5.       \-rlang:::abort_call_input_type(".call")

Adjusting the call...i put in the following....

> doc <- officer::ph_with(doc, value, location = quo(ph_location(left = 1, top = 2, width = 6, height = 4)))
Error in quo(ph_location(left = 1, top = 2, width = 6, height = 4), x = list( : 
  unused arguments (x = list("C:\\Users\\user1234567\\AppData\\Local\\Temp\\19\\RtmpmorLmI\\file11d0c51f02a5f", list("{5C22544A-7EE6-4342-B048-85BDC9FD1C3A}", NA), <environment>, <environment>, <environment>, <environment>, <environment>, list(c("dc", "dc", "dc", "cp", "dc", "cp", "cp", "dcterms", "dcterms", "cp", "title", "subject", "creator", "keywords", "description", "lastModifiedBy", "revision", "created", "modified", "category", "", "", "", "", "", "", "", " xsi:type=\"dcterms:W3CDTF\"", " xsi:type=\"dcterms:W3CDTF\"", 
"", "", "", "", "", "", "David Gohel", "3", "2017-02-13T16:18:36Z", "2017-05-26T11:05:44Z", ""), c("http://schemas.openxmlformats.org/package/2006/metadata/core-properties", "http://purl.org/dc/elements/1.1/", "http://purl.org/dc/dcmitype/", "http://purl.org/dc/terms/", "http://www.w3.org/2001/XMLSchema-instance")), 1), layout = "Title and Content", master = "Office Theme")

Removeing the quo bit....in the above...caused R to crash and automatically exit.

h.l.m
  • 13,015
  • 22
  • 82
  • 169
  • I can not reproduce, only difference is you are on a Windows Server 2008 and I am running R with Windows 10. Can you run the code in command line so that error can be read? – David Gohel Nov 04 '19 at 11:00
  • When trying to run in command line it also still exits automatically, giving an error that says: “A problem caused the program to stop working correctly” and please close the program. When trying to send output to logs, nothing gets written as I think it exits before anything can be written do you have any recommendations on how to debug. – h.l.m Nov 04 '19 at 15:07
  • was it with rstudio command line? if yes, try with windows terminal – David Gohel Nov 04 '19 at 17:07
  • I have added some additional information in the question now with the windows output....hopefully it is helpful. – h.l.m Nov 04 '19 at 17:52
  • This is far from your original issue. You were talking about a crash with RStudio with an example of the documentation. For your new issue, you can try with the dev version of officer, it is planned to send it to CRAN soon. – David Gohel Nov 06 '19 at 09:38

0 Answers0