军官使用rvg和ggplot

时间:2019-11-01 16:54:54

标签: r ggplot2 rlang officer

在尝试使用rvg选项将ggplots绘制到幻灯片时,我似乎收到了导致RStudio崩溃的错误。

文档建议类似的方法应该起作用:

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

以下是我正在使用的代码:

arr2

以下是我的会话信息:

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

删除上面的quo...。导致R崩溃并自动退出。

0 个答案:

没有答案