亚洲精品久久久久久第一页-人妻少妇精彩视品一区二区三区-91国产自拍免费视频-免费一级a在线播放视频正片-少妇天天日天天射天天爽-国产大屁股喷水视频在线观看-操美女骚穴抽插性爱视频-亚洲 欧美 中文字幕 丝袜-成人免费无码片在线观看

萬(wàn)能轉(zhuǎn)換:R圖和統(tǒng)計(jì)表轉(zhuǎn)成發(fā)表級(jí)的Word、PPT、Excel、HTML( 二 )

相關(guān)的例子) 。
鳶尾花(iris)是數(shù)據(jù)挖掘常用到的一個(gè)數(shù)據(jù)集,包含150個(gè)鳶尾花的信息,每50個(gè)取自三個(gè)鳶尾花種之一(setosa,versicolour或virginica) 。每個(gè)花的特征用下面的5種屬性描述萼片長(zhǎng)度(Sepal.Length)、萼片寬度(Sepal.Width)、花瓣長(zhǎng)度(Petal.Length)、花瓣寬度(Petal.Width)、類(Species) 。
在console里展示數(shù)據(jù)圖 (長(zhǎng)寬比自己調(diào)節(jié)):
導(dǎo)出圖形對(duì)象# 需運(yùn)行上面的ggplot2繪圖# Create a file name# 程序會(huì)自動(dòng)加后綴filen <- "output_filename" # or# filen <- paste("YOUR_DIR/ggplot")# There are 3 ways to use graph2bitmap():### 1. Pass the plot as an objectgraph2png(x=x, file=filen, dpi=400, height = 5, aspectr=4)graph2tif(x=x, file=filen, dpi=400, height = 5, aspectr=4)graph2jpg(x=x, file=filen, dpi=400, height = 5, aspectr=4)
導(dǎo)出當(dāng)前繪圖窗口展示的圖### 2. Get the plot from current screen device# 注意這個(gè)x,是運(yùn)行命令,展示圖像xgraph2png(file=filen, dpi=400, height = 5, aspectr=4)graph2tif(file=filen, dpi=400, height = 5, aspectr=4)graph2jpg(file=filen, dpi=400, height = 5, aspectr=4)
導(dǎo)出自定義函數(shù)輸出的一組圖### 3. Pass the plot as a functioplot.fun <- function(){print(qplot(Sepal.Length, Petal.Length, data = https://www.520longzhigu.com/shenghuo/iris,color = Species, size = Petal.Width, alpha = 0.7))}graph2png(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)graph2tif(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)graph2jpg(file=filen, fun=plot.fun, dpi=400, height = 5, aspectr=4)
轉(zhuǎn)換后的圖形:
與Office系列的交互大部分圖的細(xì)節(jié)修改都是用代碼完成的,不需要后續(xù)的修飾;但如果某一些修改比較特異,不具有程序的通用性特征,或?qū)崿F(xiàn)起來(lái)比較困難,就可以考慮后期修改 。比如用AI文章用圖的修改和排版 。熟悉PPT的,也可以用PPT,這時(shí)R的圖導(dǎo)出PPT,就要用到graph2office系列函數(shù)了 。
graph2ppt: 將當(dāng)前R圖保存到Microsoft Office PowerPoint/LibreOffice Impress演示文稿中 。
graph2doc:將當(dāng)前的R圖保存到Microsoft Office Word/LibreOffice Writer文檔中 。
函數(shù)參數(shù)展示和解釋
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, ...)

  • margins: 預(yù)設(shè)留白邊距向量 。
  • paper: 紙張尺寸——“A5”至“A1”用于Powerpoint導(dǎo)出,或“A5”至“A3”用于Word輸出;默認(rèn)“auto”自動(dòng)選擇適合您的圖形的紙張大小 。如果圖太大,無(wú)法在給定的紙張大小上顯示,則按比例縮小 。
  • orient: 所需的紙張方向-“自動(dòng)”,“縱向”或“橫向”; Word輸出默認(rèn)為“自動(dòng)”,Powerpoint默認(rèn)為“橫向” 。
  • vector.graphic: 指定是否以可編輯的向量DrawingML格式輸出 。默認(rèn)值為T(mén)RUE,在這種情況下,編輯Powerpoint或Word中的圖形時(shí),可以先對(duì)圖形元素進(jìn)行分組 。如果設(shè)置為FALSE,則將該圖以300 dpi的分辨率柵格化為PNG位圖格式 。(柵(shān)格化,是PS中的一個(gè)專業(yè)術(shù)語(yǔ),柵格即像素,柵格化即將矢量圖形轉(zhuǎn)化為位圖 。)
同樣有3種導(dǎo)出方式# 需運(yùn)行上面的ggplot2繪圖# Create a file namefilen <- "output_filename" # or# filen <- paste("YOUR_DIR/ggplot")# There are 3 ways to use graph2office():### 1. Pass the plot as an object# 導(dǎo)出圖形對(duì)象graph2ppt(x=x, file=filen)graph2doc(x=x, file=filen, aspectr=0.5)### 2. Get the plot from current screen device# 導(dǎo)出當(dāng)前預(yù)覽窗口呈現(xiàn)的圖xgraph2ppt(file=filen, width=9, aspectr=2, append = TRUE)graph2doc(file=filen, aspectr=1.7, append =TRUE)### 3. Pass the plot as a function# 導(dǎo)出自定義函數(shù)輸出的一系列圖graph2ppt(fun=plot.fun, file=filen, aspectr=0.5, append = TRUE)graph2doc(fun=plot.fun, file=filen, aspectr=0.5, append = TRUE)


以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問(wèn)題,請(qǐng)您及時(shí)就醫(yī)或請(qǐng)專業(yè)人士給予相關(guān)指導(dǎo)!

「愛(ài)刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對(duì)您有所幫助: