![](/img/trans.png)
[英]Displaystyle in all equations in R Markdown document entire document
[英]hiding entire pages in an r markdown document
我有下面的降價文件。 如果參數“P”不等於A,我想隱藏第2頁。
所以結果是如果參數P!= A那么只產生3頁。
這有可能嗎?
---
title: "Untitled"
output:
pdf_document:
toc: yes
params:
P: A
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
\newpage
## PAGE2
this is text for page 2
this is text for page 2
```{r cars}
summary(cars)
```
\newpage
## PAGE3
this is text for page 3
```{r pressure, echo=FALSE}
plot(pressure)
```
\newpage
## PAGE4
this is text for page 4
您可以根據P值對該部分進行評論。 這有點像一種hackish方式:用\\iffalse
/ \\fi
包圍該部分。 請注意,該部分中的R代碼仍然需要有效才能生效(它將由knitr編譯,但乳膠會忽略)。
```{r, echo=FALSE, results='asis'}
if(params$P != "A")
cat("\\iffalse")
```
## PAGE2
this is text for page 2
this is text for page 2
```{r cars}
summary(cars)
```
\newpage
```{r, echo=FALSE, results='asis'}
if(params$P != "A")
cat("\\fi")
```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.