1、Rmd文件:在R语言里面保存。会把.Rmd,.html,figure文件夹一起保存在setwd的位置
2、md文件:knitr::knit("需要转换的文件.Rmd")。注意这里tab键选择文件。导出后为一个.md文件,可以用Visual Studio Code软件打开,代码,注释和figure都在文件里
title: "第一次用Rmarkdown"
output: html_document
date: "2025-02-05"
在该界面右上角“c”里面添加代码即可,7-9行是插入的代码行。运行后下面会把运行结果写出来。且在这个时候运行的代码在保存的时候会再运行一遍,所以保存的时候运行即可。
保存的代码用Visual Studio Code调取
.md的文件导出:knitr::knit("需要转换的文件.Rmd")。注意这里tab键选择文件,先setwd到指定文件夹 引用:加上“>”符号 Knit渲染:导出一个.Rmd的文件
This 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:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
plot(cars$speed)
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。