我找不到一种方式来获得这两种文件类型。因此,如果您想创建PDF,请参阅第一个示例,并且不要使用<!-- -->
。在HTML中,您可以在文档中留下两个注释字符。
那这对PDF
title: "Untitled"
author: "Mario Dejung <[email protected]>"
date: "28 Sep 2016"
output: pdf_document
header-includes: \usepackage{comment}
---
```{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)
```
\begin{comment}
## 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.
\end{comment}
而这对于HTML
---
title: "Untitled"
author: "Mario Dejung <[email protected]>"
date: "28 Sep 2016"
output: html_document
header-includes: \usepackage{comment}
---
```{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)
```
<!--
\begin{comment}
## 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.
\end{comment}
-->
你可以使用'knitr :: opts_chunk $组(EVAL = FALSE)'设置EVAL = FALSE的命令后所有块;我不知道如何轻松地为文本做到这一点。 – scoa
感谢@scoa。我知道'chunk $ set'的使用,实际上我使用它来不评估不需要的代码并节省时间。 –
不是什么玩具要求,但因为它仍然评估文本,但不显示它在HTML中使用HTML评论'' –