使用仪表板创建可调整的R传单

时间:2019-04-24 09:50:48

标签: r shiny leaflet shinydashboard

我正在尝试在仪表板中创建传单图像。这是我到目前为止的屏幕截图:

enter image description here

我的问题显然是地图高度降低了太多。如何确定单张图表的高度(无论有无单独的侧边栏,都更具吸引力)?

那是我的代码:

---
title: "Untitled"
runtime: shiny
output: flexdashboard::flex_dashboard # !!!
---

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

qty_d <- tibble(latt = c(50, 53),
                long = c(10, 16),
                qty = c(200, 140),
                planttext = c("AAA", "BBB"))
```

Page 1
======

Column1 {.sidebar}
------------------------------------------------
```{r}
sliderInput("bubblesize",
            label = "Bubble Size",
            min = 0.01, max = 0.1, value = 0.05, step = 0.02)

```

Column2 {}
-----------------------

```{r, echo=FALSE}
renderLeaflet({
  my_size <- input$bubblesize
  leaflet() %>%
  addTiles() %>%
  addCircleMarkers(lng = ~long, lat = ~latt, 
                   popup = ~planttext,
                   radius = ~qty * my_size, data = qty_d)
})
```

致谢

1 个答案:

答案 0 :(得分:1)

this link中也存在类似的问题。

flexdashboard的解决方案是将column2代码替换为:

```{r, echo=FALSE}
output$mymap = renderLeaflet({
  my_size <- input$bubblesize
  leaflet() %>%
  addTiles() %>%
  addCircleMarkers(lng = ~long, lat = ~latt, 
                   popup = ~planttext,
                   radius = ~qty * my_size, data = qty_d)
})

leafletOutput('mymap', height=1000)
```