向flexdashboard故事板添加多个页面

a11xaf1n  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(106)

我正在尝试创建一个flexdashboard故事板,但有多个页面。这样我就可以在同一个Rmd中显示两个故事板。
为了更好地解释,下面是一个reprex Jmeter 板(Rmd),它改编自标准flexdashboard storyboard模板:

---
title: "Example Storyboard"
output: 
  flexdashboard::flex_dashboard:
    storyboard: true
    social: menu
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)

Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.

plot(mtcars[, c("wt", "hp")])

https://rstudio.github.io/leaflet/

  • Interactive panning/zooming

  • Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.

  • Create maps right from the R console or RStudio

  • Embed maps in knitr/R Markdown documents and Shiny apps

  • Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns

  • Use map bounds and mouse events to drive Shiny logic

d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.

plot(mtcars[, c("disp", "drat")])

https://github.com/rstudio/d3heatmap/

  • Highlight rows/columns by clicking axis labels

  • Click and drag over colormap to zoom in (click on colormap to zoom out)

  • Optional clustering and dendrograms, courtesy of base::heatmap

字符串
这将按预期工作,看起来如下所示:

![](https://i.stack.imgur.com/AKjq6.png)
的数据
然后,我尝试使用flexdashboard语法添加**多个页面**(即,**Page 1**和**Page 2**)(以便导航窗格具有单独的故事板),如下所示:

title: "Example Storyboard"
output:
flexdashboard::flex_dashboard:
storyboard: true
social: menu
source: embed

library(flexdashboard)

Page 1

Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.

plot(mtcars[, c("wt", "hp")])

https://rstudio.github.io/leaflet/

  • Interactive panning/zooming

  • Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.

  • Create maps right from the R console or RStudio

  • Embed maps in knitr/R Markdown documents and Shiny apps

  • Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns

  • Use map bounds and mouse events to drive Shiny logic

d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.

plot(mtcars[, c("disp", "drat")])

https://github.com/rstudio/d3heatmap/

  • Highlight rows/columns by clicking axis labels

  • Click and drag over colormap to zoom in (click on colormap to zoom out)

  • Optional clustering and dendrograms, courtesy of base::heatmap

Page 2

Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.

plot(mtcars[, c("wt", "cyl")])

https://rstudio.github.io/leaflet/

  • Interactive panning/zooming

  • Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.

  • Create maps right from the R console or RStudio

  • Embed maps in knitr/R Markdown documents and Shiny apps

  • Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns

  • Use map bounds and mouse events to drive Shiny logic

d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.

plot(mtcars[, c("disp", "drat")])

https://github.com/rstudio/d3heatmap/

  • Highlight rows/columns by clicking axis labels

  • Click and drag over colormap to zoom in (click on colormap to zoom out)

  • Optional clustering and dendrograms, courtesy of base::heatmap

型
然而,这导致以下结果:

![](https://i.stack.imgur.com/sB8HU.png)

可以看到,创建了多个页面(即**Page 1**和**Page 2**),但故事板布局被严重破坏。有人能帮助展示如何在单个浏览器中使用(多个)故事板来获得多个页面吗?
l0oc07j2

l0oc07j21#

我刚刚意识到,对于多个页面,有一个单独的功能称为故事板页面,它可以实现所需的结果。
因此,为了实现这一点,首先删除全局故事板并替换为yaml标题:

---
title: "Example Storyboard"
output: flexdashboard::flex_dashboard
---

字符串
然后我们简单地将{.storyboard}添加到每个页面标题中,例如。

Page 1 {.storyboard}
=====================================


为了完整起见,完整的故事板页面reprex如下:

---
title: "Example Storyboard"
output: 
  flexdashboard::flex_dashboard:
    # storyboard: true
    social: menu
    source: embed
---

```{r setup, include=FALSE}
library(flexdashboard)

Page 1 {.storyboard}

Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.

plot(mtcars[, c("wt", "hp")])

https://rstudio.github.io/leaflet/

  • Interactive panning/zooming

  • Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.

  • Create maps right from the R console or RStudio

  • Embed maps in knitr/R Markdown documents and Shiny apps

  • Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns

  • Use map bounds and mouse events to drive Shiny logic

d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.

plot(mtcars[, c("disp", "drat")])

https://github.com/rstudio/d3heatmap/

  • Highlight rows/columns by clicking axis labels

  • Click and drag over colormap to zoom in (click on colormap to zoom out)

  • Optional clustering and dendrograms, courtesy of base::heatmap

Page 2 {.storyboard}

Leaflet is a JavaScript library for creating dynamic maps that support panning and zooming along with various annotations.

plot(mtcars[, c("wt", "cyl")])

https://rstudio.github.io/leaflet/

  • Interactive panning/zooming

  • Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.

  • Create maps right from the R console or RStudio

  • Embed maps in knitr/R Markdown documents and Shiny apps

  • Easily render Spatial objects from the sp package, or data frames with latitude/longitude columns

  • Use map bounds and mouse events to drive Shiny logic

d3heatmap creates interactive D3 heatmaps including support for row/column highlighting and zooming.

plot(mtcars[, c("disp", "drat")])

https://github.com/rstudio/d3heatmap/

  • Highlight rows/columns by clicking axis labels

  • Click and drag over colormap to zoom in (click on colormap to zoom out)

  • Optional clustering and dendrograms, courtesy of base::heatmap

型
这将产生预期输出,如下所示:

![](https://i.stack.imgur.com/5rN1I.png)
的数据

相关问题