我正在尝试从Rmarkdown
编织HTML文档。我正在寻找一种隐藏文档的一部分,同时仍然编织(执行)所有文档的方法。
我不是不希望仅隐藏代码 chunk -这可以通过echo = FALSE
完成。
我了解flexdashboards的{.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,]
```
输出:
有什么想法吗?
答案 0 :(得分:0)
导出为html时,可以在markdown中使用任意CSS。这是一个示例:
---
title: "Untitled"
output: html_document
---
# One
Hello!
# Two
<style>
#two {
display: none;
}
</style>
```{r}
x <- 1:10
```
# Three
```{r}
plot(x)
```