Created
November 3, 2020 22:29
-
-
Save jbkunst/40b385ae2149d208b476ca10bb7dad3c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(tidyverse) | |
library(leaflet) | |
dbip <- readRDS("data/dbip.rds") | |
lista_comunas <- dbip %>% | |
count(COMUNA, sort = TRUE) %>% | |
pull(COMUNA) | |
# lista_comunas <- dbip %>% | |
# distinct(COMUNA) %>% | |
# arrange(COMUNA) %>% | |
# pull(COMUNA) | |
ui <- fluidPage( | |
titlePanel("Puntos Bip!"), | |
sidebarLayout( | |
sidebarPanel( | |
selectInput("comuna", "Comuna:", choices = lista_comunas) | |
), | |
mainPanel( | |
leafletOutput("mapa") | |
) | |
) | |
) | |
server <- function(input, output) { | |
output$mapa <- renderLeaflet({ | |
dbipcomuma <- dbip %>% | |
filter(COMUNA == input$comuna) | |
leaflet(data = dbipcomuma) %>% | |
addTiles() %>% | |
addMarkers(~LONGITUD, ~LATITUD, | |
popup = ~as.character(ENTIDAD), | |
label = ~as.character(ENTIDAD) | |
) | |
}) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment