在RStudio中,每当我制作一个新的Markdown时,它总是有默认代码。如何删除它?
这是显示的代码。
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
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:
```{r cars}
summary(cars)
```
## Including Plots
You 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.
答案 0 :(得分:5)
每次创建Rmd文件时,Rstudio都会打开一个Rmd模板:
# given a path to a folder on disk, return information about the R Markdown
# template in that folder.
.rs.addFunction("getTemplateDetails", function(path) {
# check for required files
templateYaml <- file.path(path, "template.yaml")
skeletonPath <- file.path(path, "skeleton")
if (!file.exists(templateYaml))
return(NULL)
if (!file.exists(file.path(skeletonPath, "skeleton.Rmd")))
return(NULL)
# load template details from YAML
templateDetails <- yaml::yaml.load_file(templateYaml)
# enforce create_dir if there are multiple files in /skeleton/
if (length(list.files(skeletonPath)) > 1)
templateDetails$create_dir <- TRUE
templateDetails
})
因此最简单的解决方案是:
xxx\RStudio\resources\templates
文件夹,您的位置
已安装Rstudio r_markdown_v2.Rmd
文件,然后删除
寄托都现在,每当你打开一个rmarkdown时,你就可以只拥有yaml部分。