我找不到一種方式來獲得這兩種文件類型。因此,如果您想創建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評論'' –