Используйте pickerInput и убедитесь, что все выбрано.Поскольку отображаемый набор данных поступает из фильтра (), и в раскрывающемся списке не выбран ни один исполнитель, он даст вам только подмножество, которое пусто.
##################
##################
library(shiny)
library(shinythemes)
library(leaflet)
library(leaflet.extras)
library(RColorBrewer)
library(formattable)
library(dplyr)
library(stringr)
## load data ##
murals <- read.csv("https://data.cityofchicago.org/api/views/we8h-apcf/rows.csv?accessType=DOWNLOAD",
stringsAsFactors = F, na = c("", "N/A", "NA"))
## clean data ##
# clean Media type
murals$Media <- str_replace(murals$Media, "spray", "Spray")
murals$Media <- str_replace(murals$Media, "Spray + brush", "Spray and Brush")
murals$Media <- str_replace(murals$Media, "Painting", "Paint")
murals$Media <- str_replace(murals$Media, "LAKE VIEW", "Lake View")
# clean Titles
murals$Artwork.Title <- str_replace(murals$Artwork.Title, "Where There Is Discord, Harmony:The Power of Art", "Where There Is Discord, Harmony: The Power of Art")
## make map easier to read with scalable circle markers ##
circle.scaler <- function(x){((x-min(x))/(max(x)-min(x)))*500}
##################
##################
# set UI
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("mymap", width = "100%", height = "100%"),
absolutePanel(
top = 10,
right = 10,
theme = shinytheme("lumen"),
shinyjs::inlineCSS(list(body = "color:White")),
titlePanel("Chicago Neighborhood Murals"),
pickerInput(
"Artist.Credit",
label = "Artist",
choices = c("All",
unique(as.character(
murals$Artist.Credit
))),
selected = murals$Artist.Credit,
multiple = T
)
)
)
##################
##################
# set server
server <- function(input,output, session){
filtered <- reactive({
murals[murals$Artist.Credit == input$Artist.Credit, ]
})
# define map color markers
color <- colorFactor(topo.colors(3), murals$Affiliated..or.Commissioning..Organization)
# render original leaflet map
output$mymap <- renderLeaflet({
leaflet(data = murals) %>%
addTiles() %>%
addMarkers() %>%
# add legend
addLegend(
"bottomleft", # legend position
pal = color, # color palette
values = ~Affiliated..or.Commissioning..Organization, # legend values
opacity = 1,
title = "Commissioning Organization")
})
# leaflet proxy map
observe(leafletProxy("mymap", data = filtered()) %>%
addProviderTiles("Esri.WorldImagery") %>%
clearMarkers() %>%
addCircleMarkers(lng = ~Longitude,
lat = ~Latitude,
color = ~color(Affiliated..or.Commissioning..Organization),
popup = paste("Artist:", murals$Artist.Credit, "<br>",
"Title:", murals$Artwork.Title, "<br>",
"Medium:", murals$Media, "<br>",
"Location Description:", murals$Location.Description, "<br>",
"Ward:", murals$Wards, "<br>",
"Year:", murals$Year.Installed, "<br>",
"Year Restored:", murals$Year.Restored))
)
}
shinyApp(ui = ui, server = server)