Rmarkdown HMTL输出-隐藏文档的一部分,同时仍在编织它

Rmarkdown HMTL输出-隐藏文档的一部分,同时仍在编织它,r,r-markdown,knitr,R,R Markdown,Knitr,我正试图从Rmarkdown编织一个HTML文档。我正在寻找一种方法来隐藏文档的一部分,同时仍然编织(执行)所有文档 我不是只想隐藏代码块,这可以通过echo=FALSE实现 我知道的是的{.hidden}选项,它为我提供了一部分的方法 部分从HMTL输出本身消失,但不目录 代码示例: --- output: html_document: df_print: kable fig_height: 2 fig_width: 2 number_sections:

我正试图从
Rmarkdown
编织一个HTML文档。我正在寻找一种方法来隐藏文档的一部分,同时仍然编织(执行)所有文档

我不是只想隐藏代码块,这可以通过
echo=FALSE
实现

我知道的是的
{.hidden}
选项,它为我提供了一部分的方法

部分从HMTL输出本身消失,但目录

代码示例:

---
output: 
  html_document: 
    df_print: kable
    fig_height: 2
    fig_width: 2
    number_sections: yes
    toc: yes
    toc_float: yes
editor_options: 
  chunk_output_type: console
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE,
                      warning = FALSE, 
                      message = FALSE,
                      cache = FALSE,
                      dpi = 75,
                      comment = '')
```


# 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.

# The section I want to hide {.hidden}

Super-secret text (section content I don't want to show).

```{r}
sumCars <- summary(cars)
```


# This the section I want to show again

```{r}
sumCars[1,]
```

---
输出:
html_文件:
df_打印:可折叠
fig_高度:2
fig_宽度:2
部分数量:是
toc:是的
toc_浮动:是的
编辑器选项:
块输出类型:控制台
---
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=FALSE,
警告=错误,
消息=FALSE,
cache=FALSE,
dpi=75,
注释=“”)
```
#降价
这是一份R降价文件。Markdown是一种用于编写HTML、PDF和MS Word文档的简单格式语法。有关使用R标记的更多详细信息,请参阅。
当您单击**Knit**按钮时,将生成一个文档,其中包括文档中任何嵌入的R代码块的内容和输出。您可以像这样嵌入R代码块:
```{r cars}
摘要(车辆)
```
#包括情节
还可以嵌入打印,例如:
```{r压力,回波=假}
绘图(压力)
```
请注意,“echo=FALSE”参数被添加到代码块中,以防止打印生成绘图的R代码。
#我要隐藏的部分{.hidden}
超级机密文本(我不想显示的部分内容)。
```{r}

sumCars导出为html时,可以在标记中使用任意css。以下是一个例子:


---
title: "Untitled"
output: html_document
---

# One

Hello!

# Two

<style>
 #two {
   display: none;
 }
</style>

```{r}
x <- 1:10
```

# Three

```{r}
plot(x)
```


---
标题:“无标题”
输出:html\u文档
---
#一个
你好
#两个
#两个{
显示:无;
}
```{r}

我不完全清楚:是要隐藏的代码块之间的文本,还是实际的代码块?或者两者都有?使用
include=FALSE
as chunk选项可以简单地隐藏代码块。还有一个相关的问题:如何隐藏标题部分?@LazarusThurston你可以用同样的方法隐藏标题——使用CSS设置
display:none