我创建了一个名为“widgets_t.html”的 html 文件(几个情节图组合在一起)。使用本教程(https://beta.rstudioconnect.com/jjallaire/htmlwidgets-showcase-storyboard/htmlwidgets-showcase-storyboard.html https://beta.rstudioconnect.com/jjallaire/htmlwidgets-showcase-storyboard/htmlwidgets-showcase-storyboard.html)作为演示以及此处提供的答案(如何在flexdashboard中创建下拉菜单? https://stackoverflow.com/questions/73491512/how-to-create-a-dropdown-menu-in-flexdashboard),我尝试创建一个 Rmarkdown/Flexdashboard 文档。这是我正在使用的代码(在本例中,为了简洁起见,我只是使用了相同的 html 输入和相同的文本):
---
title: "maps"
output:
flexdashboard::flex_dashboard:
storyboard: true
social: menu
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
```
```{css}
.storyboard-nav .sbframelist ul li {
height: auto;
}
```
Page 1
=====================================
Column {.tabset}
-------------------------------------
### Title 1
<object type="text/html" width="1500" height="1500" data="widgets_t.html"></object>
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
### Title 2 {.tabset .tabset-dropdown}
<object type="text/html" width="1500" height="1500" data="widgets_t.html"></object>
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
Page 2
=====================================
<object type="text/html" width="1500" height="1500" data="widgets_t.html"></object>
- 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
Page 3
=====================================
<object type="text/html" width="1500" height="1500" data="widgets_t.html"></object>
- 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
上面的代码成功运行并以我期望的格式呈现输出,但文本(例如“Compose maps using arbitrary combinations of map tiles, markers, polygons, lines, popups, and GeoJSON.
" ) 没有出现。
谢谢你!
PS:这是“widgets_t.html”的示例:
library(plotly)
libtary(htmltools)
library(htmlwidgets)
fig <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length)
doc <- htmltools::tagList(
div(fig, style = "float:left;width:50%;")
)
htmltools::save_html(html = doc, file = "widgets_t.html")