html_document 中的目录 wtih shiny 不起作用
Toc in html_document wtih shiny does not work
我准备了非常简单的带有闪亮小部件的 rmarkdown 文档。我想添加 table 的内容,但尽管我使用 toc: yes
它根本不起作用,为什么?
---
title: "Test document"
author: "XXX"
date: "XXX"
output:
html_document:
toc: yes
runtime: shiny
---
```{r, echo = FALSE}
h2('R package')
br()
h3('Ggplot2')
br()
h4('Mtcars')
library(ggplot2)
data(mtcars)
selectInput('name', 'Choose a cylinder:',
choices = sort(unique(mtcars$cyl)),
selected = sort(unique(mtcars$cyl))[1])
data <- reactive(subset(mtcars,cyl == input$name))
number <- reactive(which(sort(unique(mtcars$cyl)) == input$name))
renderPlot(ggplot(data(),aes(qsec, mpg))+
geom_point(size = 6))
```
您的 headers 需要在代码块 之外,以便 table 的内容能够捕获它们。
然后,您应该使用适当数量的 #
而不是 html 样式来可视化 headers 大小。
另请注意目录深度默认为三,因此在您的情况下 mtcars 不会出现在目录中,除非您将 toc_depth
调整为 4。
这应该可以满足您的要求:
---
title: "Test document"
author: "XXX"
date: "XXX"
output:
html_document:
toc: TRUE
toc_depth: 4
runtime: shiny
---
## R package
### ggplot2
#### mtcars
```{r, echo = FALSE}
library(ggplot2)
data(mtcars)
selectInput('name', 'Choose a cylinder:',
choices = sort(unique(mtcars$cyl)),
selected = sort(unique(mtcars$cyl))[1])
data <- reactive(subset(mtcars,cyl == input$name))
number <- reactive(which(sort(unique(mtcars$cyl)) == input$name))
renderPlot(ggplot(data(),aes(qsec, mpg))+
geom_point(size = 6))
```
旁注:即使它正在工作,使用 toc: TRUE
而不是 toc: yes
更常见
我准备了非常简单的带有闪亮小部件的 rmarkdown 文档。我想添加 table 的内容,但尽管我使用 toc: yes
它根本不起作用,为什么?
---
title: "Test document"
author: "XXX"
date: "XXX"
output:
html_document:
toc: yes
runtime: shiny
---
```{r, echo = FALSE}
h2('R package')
br()
h3('Ggplot2')
br()
h4('Mtcars')
library(ggplot2)
data(mtcars)
selectInput('name', 'Choose a cylinder:',
choices = sort(unique(mtcars$cyl)),
selected = sort(unique(mtcars$cyl))[1])
data <- reactive(subset(mtcars,cyl == input$name))
number <- reactive(which(sort(unique(mtcars$cyl)) == input$name))
renderPlot(ggplot(data(),aes(qsec, mpg))+
geom_point(size = 6))
```
您的 headers 需要在代码块 之外,以便 table 的内容能够捕获它们。
然后,您应该使用适当数量的 #
而不是 html 样式来可视化 headers 大小。
另请注意目录深度默认为三,因此在您的情况下 mtcars 不会出现在目录中,除非您将 toc_depth
调整为 4。
这应该可以满足您的要求:
---
title: "Test document"
author: "XXX"
date: "XXX"
output:
html_document:
toc: TRUE
toc_depth: 4
runtime: shiny
---
## R package
### ggplot2
#### mtcars
```{r, echo = FALSE}
library(ggplot2)
data(mtcars)
selectInput('name', 'Choose a cylinder:',
choices = sort(unique(mtcars$cyl)),
selected = sort(unique(mtcars$cyl))[1])
data <- reactive(subset(mtcars,cyl == input$name))
number <- reactive(which(sort(unique(mtcars$cyl)) == input$name))
renderPlot(ggplot(data(),aes(qsec, mpg))+
geom_point(size = 6))
```
旁注:即使它正在工作,使用 toc: TRUE
而不是 toc: yes