我正在尝试创建一个interactive document,如Shiny网站上的教程。但是,我希望该图成为单张地图。在Leaflet tutorial之后,似乎以下应该使用leaflet::renderLeaflet()
而不是shiny::renderPlot()
来工作。
相反,运行文档Error: object 'input' not found
时出现错误。在交互式Rmarkdown文档中使用Shiny小部件时,是否有一种特殊的方法将input
暴露给传单?
---
runtime: shiny
output: html_document
---
```{r echo = FALSE}
library(magrittr)
shiny::selectInput(
"weight", label = "Weight:",
choices = c(1, 2, 3, 4, 5), selected = 5
)
```
```{r include = FALSE}
csa <- tigris::combined_statistical_areas(class = "sf")
```
```{r echo = FALSE}
leaflet::renderLeaflet({ # <- main difference from tutorial
leaflet::leaflet() %>%
leaflet::addTiles() %>%
leaflet::addPolylines(data = csa, color = '#333', weight = input$weight)
})
```
答案 0 :(得分:0)