之前为export
参考文献:https://cran.r-project.org/web/packages/export/export.pdf
graph2office
Save currently active R graph to Microsoft Office / LibreOffice format
将目前的R图像保存为Microsoft Office或LibreOffice格式。Usage
graph2office(x = NULL, file = "Rplot", fun = NULL, type = c("PPT",
"DOC"), append = FALSE, aspectr = NULL, width = NULL, height = NULL,
scaling = 100, paper = "auto", orient = ifelse(type[1] == "PPT",
"landscape", "auto"), margins = c(top = 0.5, right = 0.5, bottom = 0.5, left
= 0.5), center = TRUE, offx = 1, offy = 1, upscale = FALSE,
vector.graphic = TRUE, ...)Arguments参数
x
given ggplot2 plot or lattice plot object to export; if set to NULL the currently active R graph will be exported; not supported for base R plots.
给定要导出的ggplot2 plot或lattice plot对象;如果设置为空,将导出当前活动的R图;不支持R基本函数
file
name of output file. Any extension is ignored and added according to the requested output type.
输出文件的名称。忽略任何扩展名并根据要输出文件的类型添加。
fun
plot passed on as a function used to create it; useful especially for base R plots.
作为创建它的函数传递的绘图;特别适用于R基本绘图
type
desired output type - DOC for Word document, PPT for Powerpoint.
期望输出类型- Word文档为DOC,Powerpoint为PPT 。
append
logical value - if TRUE and type=PPT it will append the graph to the given file, where file can also be a given corporate template. If append=FALSE any existing file will be overwritten. Currently ignored in Word export.
逻辑值-如果append=TRUE,并且type=PPT,它将把图形附加到给定的文件中,其中的文件也可以是给定的公司模板。如果append=FALSE,任何现有文件将被覆盖。在导出的Word中被忽略。
aspectr
desired width to height aspect ratio. If set to NULL, the aspect ratio of the active graphics device is used.
所需的宽高比。如果设置为空,则使用活动图形设备的宽高比。
width
desired width in inches; can be combined with a desired aspect ratio aspectr.
所需宽度(英寸);可与所需宽高比参数aspectr组合
height
desired height in inches; can be combined with a desired aspect ratio aspectr.
所需高度(英寸);可与所需宽高比参数aspectr组合
scaling
scale width & height by a certain percentage.
按一定百分比缩放宽度和高度。
paper
desired paper size to use - "A5" to "A1" for Powerpoint export, or "A5" to "A3" for Word output; default "auto" automatically selects the paper size that fits your graph. Graphs that are too large to fit on a given paper size are scaled down.
定义纸张大小-“A5”到“A1”用于Powerpoint导出,“A5”到“A3”用于Word输出;默认“自动”会自动选择适合图形的纸张大小。如果图形太大而无法适应给定的纸张大小,则会缩小比例。
orient
desired paper orientation - "auto", "portrait" or "landscape"; default to "auto" for Word output and to "landscape" for Powerpoint.
定义纸张方向-“自动”、“纵向”或“横向”;默认Word 为“自动”,Powerpoint为“横向”。
margins
vector with the desired margins that should be left blank in
定义所需边距,该边距在左空白
center
logical specifying whether or not to center the graph in the exported Powerpoint.
指定导出的图形在Powerpoint中是否居中。
offx
if center is set to FALSE, the desired x offset at which to place one’s graph in Powerpoint output.
如果center设置为FALSE,则在Powerpoint输出中放置图形所需的x偏移量。
offy
if center is set to FALSE, the desired y offset at which to place one’s graph in Powerpoint output.
upscale
logical specifying whether or not to upscale one’s graph to make it page-filling (excluding the margins). Note that scaling may result in a different look of one’s graph relative to how it looks on the screen due to the change in size.
逻辑上指定是否将图形放大以使其填充页面(不包括页边距)。请注意,由于大小的变化,缩放可能会导致图形的外观与屏幕上的外观不同。
vector.graphic
logical specifying whether or not to output in editable, vector DrawingML format. Defaults to TRUE, in which case editing the plot in Powerpoint or Word is then possible after first ungrouping the plot elements. If set to FALSE, the plot is rasterized to PNG bitmap format at a resolution of 300 dpi.
指定是否以可编辑的矢量DrawingML格式输出。默认为TRUE,在这种情况下,可以在Powerpoint或Word中第一次解组plot元素后编辑绘图。如果设置为FALSE,打印将以300 dpi的分辨率光栅化为PNG位图格式。
...
any other options are passed on to rvg’s dml_pptx function.
任何其他选项都会传递给rvg的dml_pptx函数。
1.安装和载入
install.packages("eoffice")
library(eoffice)
2.导出为ppt
topptx(filename ="mtcars.pptx")