日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

R语言观察日志(part6)--初识rMarkdown

發布時間:2023/12/19 编程问答 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 R语言观察日志(part6)--初识rMarkdown 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

學習筆記,僅供參考,有錯必糾

官方文檔:rmarkdown



R Markdwon


初識R Markdown


創建一個R Markdwon:



選擇html為輸出格式,并給自己的文檔起一個名字:

點擊OK,系統自動生成一個示例Rmarkdown:

--- title: "myRmarkdwon" author: "goatbishop" date: "2020年7月9日" output: html_document ---```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ```## R MarkdownThis is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:```{r cars} summary(cars) ```## Including PlotsYou can also embed plots, for example:```{r pressure, echo=FALSE} plot(pressure) ```Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

我們對R Markdown 里的內容進行修改:

--- title: "myRmarkdwon" author: "goatbishop" date: "2020年7月9日" output: html_document ---```{r setup, include=FALSE} knitr::opts_chunk$set(echo = TRUE) ```設置include參數為False,可以使代碼及結果都不顯示在報告中### 我的第一個R Markdown```{r cars} summary(cars) print("Hello Goatbishop, Welcome to R Markdown") ```### 繪圖```{r pressure, echo=FALSE} plot(pressure) ```我們設置echo參數為False,可以使代碼不顯示在報告中。

點擊保存生成Rmd文件:


再新建一個R腳本,敲入如下代碼,就可以生成HTML報告文件:

library(rmarkdown) render("test2.Rmd")

我們看一下Rstudio中的輸出結果:

> render("test2.Rmd")processing file: test2.Rmd|................ | 14%ordinary text without R code|................................ | 29% label: setup (with options) List of 1$ include: logi FALSE|................................................ | 43%ordinary text without R code|............................................................... | 57% label: cars|............................................................................... | 71%ordinary text without R code|............................................................................................... | 86% label: pressure (with options) List of 1$ echo: logi FALSE|...............................................................................................................| 100%ordinary text without R codeoutput file: test2.knit.md"F:/software/Rstudio/bin/pandoc/pandoc" +RTS -K512m -RTS test2.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output test2.html --email-obfuscation none --self-contained --standalone --section-divs --template "F:\software\R-3.6.2\library\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\GOATBI~1\AppData\Local\Temp\RtmpKMmluQ\rmarkdown-str4f025ca3a60.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"

再看看新生成的test2.html文件:

打開它:

額,感覺我設計的有點問題,頁面很不美觀啊!沒關系,之后我們會繼續學習相關知識點的!

總結

以上是生活随笔為你收集整理的R语言观察日志(part6)--初识rMarkdown的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。