Сотрудник, использующий rvg и ggplot - PullRequest
0 голосов
/ 01 ноября 2019

Я получаю сообщение об ошибке, которая приводит к сбою RStudio при попытке использовать параметры rvg для построения ggplots на слайде при использовании офицера.

Документация предполагает, что нечто подобное должно работать:

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

Ниже код, который я использую:

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") 

Ниже моя сессия Информация:

> 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

Я сломал оригиналпроблема Теперь я получаю следующее сообщение об ошибке:

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")

Настройка вызова ... я вставил следующее ....

> 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")

Удаление бит кво .... в приведенном выше ... вызвал сбой R и автоматически выйти.

...