r-为什么我不能将网格中的一组绘图发送给带官员的PowerPoint? [英] r - Why can't I send a group of plots in a grid to PowerPoint with officer?

查看:115
本文介绍了r-为什么我不能将网格中的一组绘图发送给带官员的PowerPoint?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用gridextra创建了一个qicharts2地块网格,但是当我尝试使用高级职员将其发送到PowerPoint时,却出现此错误.

I've created a grid of qicharts2 plots using gridextra but when I try to send it to PowerPoint using officer I get this error..

doc_parse_raw(x,编码=编码,base_url = base_url,as_html = as_html,错误: StartTag:无效的元素名称[68]

Error in doc_parse_raw(x, encoding = encoding, base_url = base_url, as_html = as_html, : StartTag: invalid element name [68]

这是我的代码:

library(qicharts2)
library(gridExtra)
library(officer)
library(rvg)



#24 random numbers from a normal distribution for example.
y1 <- rnorm(24)
y2 <- rnorm(24)

yC1 <- qic(y1)
yC2 <- qic(y2)

grid <- grid.arrange(yC1,yC2)


filename <- "C:\\Desktop\\MyCharts.pptx"


read_pptx(filename) %>% 

  add_slide(layout = "Title and Content", master = "Office Theme") %>% 
  ph_with_vg(code = print(grid), type = "body") %>% 
  print(target = filename) %>% 
  invisible()

非常感谢大家对到目前为止如何改善我的问题的建议.

Huge thanks to everyone for your advice on how to improve my question so far.

任何获得进一步帮助的帮助

Any help further help greatly received

推荐答案

使用grid.arrange时,您正在绘图,此处的打印方法无用(print(grid)对图形没有影响设备).以下适用于grid.arrange:

When using grid.arrange, you are plotting, the print method is not useful here (print(grid) had no effect on graphical device). The following is working with grid.arrange:

library(qicharts2)
library(gridExtra)
library(officer)
library(rvg)
library(magrittr)

#24 random numbers from a normal distribution for example.
y1 <- rnorm(24)
y2 <- rnorm(24)

yC1 <- qic(y1)
yC2 <- qic(y2)

read_pptx() %>% 
  add_slide(layout = "Title and Content", master = "Office Theme") %>% 
  ph_with_vg(code = grid.arrange(yC1,yC2), type = "body") %>% 
  print(target = "filename.pptx") %>% 
  browseURL()

这篇关于r-为什么我不能将网格中的一组绘图发送给带官员的PowerPoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆