与R Shiny和传单的交互式等值线图

时间:2015-09-18 15:01:45

标签: r shiny leaflet

我正在尝试创建一个闪亮的应用程序,我可以在其中选择我想要绘制到我的地图中的值。这可能是一个非常容易的任务,但我是Shiny的新手,我无法弄明白。

我不明白我是否必须使用selectInput,或者传单是否有与Shiny交互的不同方式。

这是我的代码

library(RColorBrewer)
library(rgdal)
library(shiny)


pal <- colorQuantile("YlGn", NULL, n = 5)

state_popup <- paste0("<strong>State: </strong>", 
                      africa$COUNTRY, 
                      "<br><strong>Resource Revenue(IMF)</strong>", 
                      africa$Africa_r_1)

leaflet_africa <- leaflet(data = africa) %>%
  addProviderTiles("CartoDB.Positron") %>%
  addPolygons(fillColor = ~pal(Africa_r_1), 
              fillOpacity = 0.8, 
              color = "#BDBDC3", 
              weight = 1, 
              popup = state_popup)



ui <- fluidPage(
  leafletOutput("map1")
  )


server <- function(input, output, session) {

  output$map1 <- renderLeaflet({
    leaflet_africa
  })
}

shinyApp(ui = ui, server = server)

0 个答案:

没有答案
相关问题