我一直在尝试创建一张显示事件发生地点的传单地图。但到目前为止我还无法创建它。地图应该对侧边栏面板上存在的变量 -“日期”和“现场”做出反应。在这里,On_site 仅采用二进制值:True/False
Dataframe 包含以下变量:incident_number、Address、纬度、经度、Date、On_site
ui.R
library(shiny)
library(leaflet)
library(tidyverse)
library(DT)
library(dplyr)
# Dataframe
incident <- read.csv('incident.csv')
ui <- fluidPage(
br(),
# Sidebar layout with a input and output definitions
sidebarLayout(
# Inputs:
sidebarPanel(
# Text instructions
HTML(paste("Customize the map by:")),
dateInput("Date", label = "Date", value = "10/15/2018",
min = "2018-10-03", max = "2018-11-01"),
hr(),
fluidRow(column(3, verbatimTextOutput("value"))),
selectInput("On_site", label = "On site",
choices = unique(incident$On_site)),
),
# Outputs:
mainPanel(
# leaflet map
leafletOutput("mymap"),
# Show data table
dataTableOutput(outputId = "incident_table"),
br()
)
)
)
服务器.R
# Define server function
server <- function(input, output) {
# Create map
filtered <- reactive({
incident %>%
filter(Date == input$Date & On_site == input$On_site)
})
output$mymap <- renderLeaflet({
leaflet() %>% addTiles() %>%
addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
fitBounds(~min(longitude), ~min(latitude), ~max(longitude), ~max(latitude))
})
observe({
leafletProxy("mymap") %>%
clearShapes()%>%
clearPopups()%>%
clearMarkers()%>%
addMarkers(lat = filtered()$latitude,
lng = filtered()$longitude,
popup = ~paste0("<strong>", filtered()$incident_number, "</strong><br/>","On_site: ", filtered()$On_site, "<br />")
)
})
# Create data table
output$incident_detail <- DT::renderDataTable({
filtered()
})
}
# Create a Shiny app object
shinyApp(ui = ui, server = server)
数据帧的前几条记录:
structure(list(incident_number = structure(c(588L, 567L, 495L,
571L, 532L, 1227L, 561L, 582L, 536L, 569L, 621L, 664L, 530L,
525L, 566L, 572L, 485L, 1221L, 528L, 585L), .Label = c("10-95413",
"18-0089255", "18-0092103", "18-090383", "18-090968", "18-091582",
"18-092639", "18-092642", "18-76029", "18-87045", "18-88746",
"18-88784", "18-88786", "18-88802", "18-88839", "18-88845", "18-88846",
"18-88889", "18-88907", "18-88913", "18-88919", "18-88920", "18-88927",
"18-88932", "18-88941", "18-88949", "18-88952", "18-88960", "18-88964",
"18-88968", "18-88980", "18-88982", "18-88984", "18-88987", "18-88990",
"18-88995", "18-88996", "18-89000", "18-89005", "18-89009", "18-89020",
"18-89023", "18-89029", "18-89031", "18-89034", "18-89042", "18-89045",
"18-89046", "18-89059", "18-89063", "18-89071", "18-89072", "18-89074",
"18-89077", "18-89091", "18-89094", "18-89096", "18-89099", "18-89107",
"18-89133", "18-89143", "18-89148", "18-89149", "18-89152", "18-89159",
"18-89161", "18-89166", "18-89167", "18-89176", "18-89187", "18-89195",
"18-89200", "18-89202", "18-89213", "18-89218", "18-89226", "18-89233",
"18-89246", "18-89247", "18-89260", "18-89273", "18-89274", "18-89279",
"18-89286", "18-89294", "18-89296", "18-89298", "18-89313", "18-89316",
"18-89317", "18-89318", "18-89319", "18-89320", "18-89326", "18-89333",
"18-89338", "18-89339", "18-89340", "18-89342", "18-89344", "18-89350",
"18-89354", "18-89355", "18-89358", "18-89359", "18-89364", "18-89365",
"18-89378", "18-89384", "18-89390", "18-89394", "18-89399", "18-89406",
"18-89407", "18-89423", "18-89463", "18-89472", "18-89476", "18-89494",
"18-89495", "18-89502", "18-89506", "18-89509", "18-89511", "18-89512",
"18-89513", "18-89520", "18-89522", "18-89533", "18-89559", "18-89564",
"18-89565", "18-89567", "18-89569", "18-89573", "18-89577", "18-89580",
"18-89585", "18-89591", "18-89596", "18-89599", "18-89605", "18-89607",
"18-89610", "18-89614", "18-89616", "18-89619", "18-89620", "18-89625",
"18-89631", "18-89633", "18-89634", "18-89639", "18-89645", "18-89646",
"18-89649", "18-89651", "18-89663", "18-89664", "18-89666", "18-89667",
"18-89692", "18-89694", "18-89700", "18-89703", "18-89704", "18-89709",
"18-89716", "18-89718", "18-89725", "18-89733", "18-89750", "18-89762",
"18-89764", "18-89777", "18-89781", "18-89792", "18-89800", "18-89802",
"18-89809", "18-89815", "18-89824", "18-89835", "18-89838", "18-89843",
"18-89859", "18-89866", "18-89870", "18-89873", "18-89874", "18-89885",
"18-89908", "18-89913", "18-89925", "18-89933", "18-89942", "18-89944",
"18-89946", "18-89948", "18-89950", "18-89954", "18-89958", "18-89976",
"18-89991", "18-90004", "18-90008", "18-90023", "18-90032", "18-90035",
"18-90053", "18-90062", "18-90066", "18-90067", "18-90069", "18-90074",
"18-90079", "18-90115", "18-90117", "18-90119", "18-90122", "18-90124",
"18-90126", "18-90127", "18-90128", "18-90130", "18-90132", "18-90138",
"18-90154", "18-90158", "18-90159", "18-90160", "18-90170", "18-90227",
"18-90229", "18-90230", "18-90242", "18-90246", "18-90248", "18-90250",
"18-90251", "18-90252", "18-90254", "18-90257", "18-90273", "18-90283",
"18-90285", "18-90302", "18-90309", "18-90310", "18-90333", "18-90349",
"18-90362", "18-90364", "18-90394", "18-90395", "18-90408", "18-90410",
"18-90416", "18-90417", "18-90425", "18-90435", "18-90440", "18-90449",
"18-90450", "18-90464", "18-90474", "18-90475", "18-90479", "18-90483",
"18-90487", "18-90492", "18-90495", "18-90498", "18-90504", "18-90509",
"18-90518", "18-90520", "18-90522", "18-90529", "18-90539", "18-90540",
"18-90554", "18-90559", "18-90569", "18-90579", "18-90580", "18-90582",
"18-90584", "18-90586", "18-90588", "18-90598", "18-90606", "18-90607",
"18-90612", "18-90624", "18-90643", "18-90653", "18-90656", "18-90658",
"18-90660", "18-90662", "18-90663", "18-90668", "18-90669", "18-90672",
"18-90676", "18-90677", "18-90680", "18-90686", "18-90687", "18-90688",
"18-90690", "18-90693", "18-90695", "18-90698", "18-90707", "18-90708",
"18-90710", "18-90726", "18-90735", "18-90736", "18-90737", "18-90738",
"18-90751", "18-90752", "18-90753", "18-90755", "18-90757", "18-90759",
"18-90772", "18-90776", "18-90778", "18-90790", "18-90804", "18-90809",
"18-90820", "18-90821", "18-90824", "18-90825", "18-90826", "18-90833",
"18-90836", "18-90837", "18-90842", "18-90844", "18-90847", "18-90849",
"18-90850", "18-90860", "18-90862", "18-90878", "18-90894", "18-90900",
"18-90929", "18-90932", "18-90942", "18-90959", "18-90964", "18-90966",
"18-90967", "18-90969", "18-90970", "18-90971", "18-90977", "18-90985",
"18-90993", "18-90994", "18-91005", "18-91028", "18-91044", "18-91046",
"18-91056", "18-91062", "18-91073", "18-91080", "18-91090", "18-91095",
"18-91117", "18-91118", "18-91122", "18-91124", "18-91131", "18-91132",
"18-91134", "18-91135", "18-91140", "18-91142", "18-91148", "18-91151",
"18-91155", "18-91163", "18-91188", "18-91202", "18-91203", "18-91223",
"18-91225", "18-91258", "18-91262", "18-91263", "18-91264", "18-91266",
"18-91267", "18-91270", "18-91276", "18-91277", "18-91278", "18-91290",
"18-91291", "18-91297", "18-91310", "18-91311", "18-91314", "18-91329",
"18-91333", "18-91337", "18-91343", "18-91350", "18-91353", "18-91360",
"18-91374", "18-91380", "18-91395", "18-91396", "18-91402", "18-91407",
"18-91412", "18-91415", "18-91422", "18-91426", "18-91431", "18-91445",
"18-91451", "18-91459", "18-91472", "18-91485", "18-91489", "18-91509",
"18-91536", "18-91548", "18-91554", "18-91557", "18-91565", "18-91566",
"18-91568", "18-91573", "18-91575", "18-91581", "18-91587", "18-91602",
"18-91608", "18-91614", "18-91633", "18-91648", "18-91654", "18-91657",
"18-91661", "18-91662", "18-91666", "18-91670", "18-91678", "18-91679",
"18-91682", "18-91686", "18-91694", "18-91696", "18-91699", "18-91702",
"18-91704", "18-91710", "18-91712", "18-91719", "18-91724", "18-91726",
"18-91733", "18-91734", "18-91743", "18-91748", "18-91757", "18-91758",
"18-91761", "18-91767", "18-91778", "18-91801", "18-91802", "18-91803",
"18-91805", "18-91813", "18-91815", "18-91816", "18-91818", "18-91820",
"18-91826", "18-91836", "18-91841", "18-91851", "18-91860", "18-91865",
"18-91875", "18-91891", "18-91898", "18-91902", "18-91904", "18-91907",
"18-91911", "18-91912", "18-91920", "18-91921", "18-91922", "18-91923",
"18-91924", "18-91930", "18-91934", "18-91935", "18-91937", "18-91945",
"18-91946", "18-91953", "18-91982", "18-92005", "18-92006", "18-92016",
"18-92022", "18-92024", "18-92036", "18-92043", "18-92045", "18-92049",
"18-92050", "18-92051", "18-92053", "18-92068", "18-92078", "18-92114",
"18-92117", "18-92118", "18-92132", "18-92133", "18-92166", "18-92169",
"18-92171", "18-92172", "18-92174", "18-92182", "18-92183", "18-92195",
"18-92206", "18-92232", "18-92261", "18-92268", "18-92272", "18-92289",
"18-92299", "18-92306", "18-92311", "18-92321", "18-92326", "18-92334",
"18-92337", "18-92339", "18-92343", "18-92344", "18-92345", "18-92349",
"18-92352", "18-92353", "18-92357", "18-92362", "18-92364", "18-92368",
"18-92371", "18-92375", "18-92376", "18-92379", "18-92386", "18-92387",
"18-92391", "18-92404", "18-92410", "18-92412", "18-92429", "18-92440",
"18-92441", "18-92444", "18-92447", "18-92459", "18-92475", "18-92476",
"18-92482", "18-92484", "18-92485", "18-92486", "18-92499", "18-92505",
"18-92507", "18-92511", "18-92521", "18-92523", "18-92531", "18-92541",
"18-92556", "18-92557", "18-92565", "18-92566", "18-92597", "18-92602",
"18-92610", "18-92611", "18-92613", "18-92615", "18-92619", "18-92620",
"18-92621", "18-92622", "18-92625", "18-92626", "18-92632", "18-92633",
"18-92635", "18-92641", "18-92644", "18-92645", "18-92649", "18-92651",
"18-92653", "18-92654", "18-92656", "18-92659", "18-92660", "18-92664",
"18-92665", "18-92684", "18-92702", "18-92714", "18-92715", "18-92721",
"18-92723", "18-92735", "18-92742", "18-92749", "18-92757", "18-92774",
"18-92777", "18-92795", "18-92811", "18-92813", "18-92814", "18-92817",
"18-92822", "18-92823", "18-92827", "18-92829", "18-92843", "18-92848",
"18-92858", "18-92865", "18-92866", "18-92878", "18-92883", "18-92903",
"18-92914", "18-92915", "18-92929", "18-92933", "18-92937", "18-92946",
"18-92947", "18-92948", "18-92950", "18-92954", "18-92955", "18-92956",
"18-92961", "18-92962", "18-92970", "18-92977", "18-92991", "18-93004",
"18-93009", "18-93014", "18-93020", "18-93025", "18-93029", "18-93033",
"18-93034", "18-93039", "18-93083", "18-93105", "18-93108", "18-93112",
"18-93116", "18-93119", "18-93124", "18-93128", "18-93134", "18-93137",
"18-93140", "18-93143", "18-93156", "18-93157", "18-93159", "18-93164",
"18-93167", "18-93168", "18-93179", "18-93184", "18-93185", "18-93196",
"18-93224", "18-93226", "18-93229", "18-93231", "18-93232", "18-93234",
"18-93235", "18-93240", "18-93244", "18-93245", "18-93253", "18-93255",
"18-93256", "18-93259", "18-93293", "18-93306", "18-93316", "18-93324",
"18-93343", "18-93345", "18-93354", "18-93357", "18-93363", "18-93365",
"18-93378", "18-93381", "18-93388", "18-93391", "18-93408", "18-93415",
"18-93444", "18-93446", "18-93449", "18-93451", "18-93462", "18-93464",
"18-93477", "18-93485", "18-93493", "18-93506", "18-93524", "18-93529",
"18-93530", "18-93532", "18-93534", "18-93536", "18-93537", "18-93538",
"18-93539", "18-93541", "18-93542", "18-93544", "18-93545", "18-93551",
"18-93559", "18-93569", "18-93573", "18-93579", "18-93583", "18-93589",
"18-93592", "18-93599", "18-93602", "18-93605", "18-93606", "18-93607",
"18-93609", "18-93614", "18-93617", "18-93621", "18-93628", "18-93630",
"18-93635", "18-93644", "18-93645", "18-93646", "18-93650", "18-93662",
"18-93669", "18-93673", "18-93675", "18-93680", "18-93694", "18-93711",
"18-93715", "18-93716", "18-93719", "18-93724", "18-93728", "18-93731",
"18-93737", "18-93753", "18-93754", "18-93755", "18-93770", "18-93774",
"18-93777", "18-93789", "18-93804", "18-93820", "18-93840", "18-93843",
"18-93846", "18-93848", "18-93852", "18-93862", "18-93867", "18-93868",
"18-93873", "18-93878", "18-93895", "18-93913", "18-93915", "18-93916",
"18-93936", "18-93937", "18-93945", "18-93951", "18-93956", "18-93965",
"18-93979", "18-93980", "18-93985", "18-93991", "18-93992", "18-94005",
"18-94021", "18-94028", "18-94030", "18-94035", "18-94039", "18-94052",
"18-94055", "18-94062", "18-94072", "18-94082", "18-94105", "18-94121",
"18-94125", "18-94143", "18-94159", "18-94176", "18-94182", "18-94186",
"18-94189", "18-94190", "18-94195", "18-94203", "18-94204", "18-94206",
"18-94229", "18-94253", "18-94268", "18-94274", "18-94290", "18-94292",
"18-94293", "18-94332", "18-94334", "18-94343", "18-94347", "18-94372",
"18-94373", "18-94389", "18-94392", "18-94393", "18-94409", "18-94414",
"18-94427", "18-94436", "18-94438", "18-94448", "18-94481", "18-94485",
"18-94529", "18-94530", "18-94548", "18-94558", "18-94561", "18-94572",
"18-94576", "18-94580", "18-94583", "18-94591", "18-94598", "18-94617",
"18-94621", "18-94640", "18-94641", "18-94643", "18-94671", "18-94673",
"18-94677", "18-94678", "18-94680", "18-94685", "18-94690", "18-94695",
"18-94697", "18-94701", "18-94704", "18-94707", "18-94739", "18-94748",
"18-94762", "18-94770", "18-947743", "18-94781", "18-94784",
"18-94792", "18-94793", "18-94800", "18-94803", "18-94809", "18-94813",
"18-94822", "18-94825", "18-94841", "18-94842", "18-94845", "18-94850",
"18-94851", "18-94853", "18-94855", "18-94859", "18-94860", "18-94865",
"18-94866", "18-94868", "18-94874", "18-94882", "18-94883", "18-94884",
"18-94886", "18-94897", "18-94908", "18-94923", "18-94958", "18-94988",
"18-94990", "18-94993", "18-94997", "18-95001", "18-95028", "18-95037",
"18-95041", "18-95045", "18-95049", "18-95050", "18-95054", "18-95056",
"18-95059", "18-95062", "18-95063", "18-95064", "18-95072", "18-95074",
"18-95076", "18-95093", "18-95099", "18-95100", "18-95103", "18-95107",
"18-95111", "18-95113", "18-95132", "18-95133", "18-95134", "18-95138",
"18-95139", "18-95147", "18-95161", "18-95167", "18-95168", "18-95172",
"18-95175", "18-95178", "18-95181", "18-95183", "18-95203", "18-95207",
"18-95208", "18-95210", "18-95211", "18-95214", "18-95217", "18-95218",
"18-95222", "18-95224", "18-95225", "18-95232", "18-95235", "18-95279",
"18-95287", "18-95294", "18-95304", "18-95307", "18-95315", "18-95322",
"18-95324", "18-95328", "18-95336", "18-95343", "18-95346", "18-95347",
"18-95348", "18-95354", "18-95361", "18-95363", "18-95366", "18-95379",
"18-95398", "18-95416", "18-95417", "18-95427", "18-95428", "18-95440",
"18-95462", "18-95479", "18-95498", "18-95515", "18-95518", "18-95519",
"18-95520", "18-95527", "18-95544", "18-95546", "18-95548", "18-95551",
"18-95555", "18-95559", "18-95563", "18-95565", "18-95570", "18-95591",
"18-95602", "18-95617", "18-95627", "18-95642", "18-95644", "18-95648",
"18-95653", "18-95658", "18-95659", "18-95661", "18-95665", "18-95671",
"18-95672", "18-95673", "18-95689", "18-95706", "18-95715", "18-95722",
"18-95725", "18-95727", "18-95728", "18-95732", "18-95733", "18-95737",
"18-95742", "18-95773", "18-95775", "18-95790", "18-95792", "18-95798",
"18-95814", "18-95816", "18-95817", "18-95822", "18-95841", "18-95844",
"18-95868", "18-95873", "18-95875", "18-95878", "18-95891", "18-95909",
"18-95913", "18-95922", "18-95927", "18-95954", "18-95957", "18-95965",
"18-95967", "18-95990", "18-96009", "18-96011", "18-96016", "18-96040",
"18-96051", "18-96057", "18-96101", "18-96157", "18-96167", "18-96178",
"18-96181", "18-96187", "18-96201", "18-96230", "18-96240", "18-96263",
"18-96307", "18-96338", "18-96353", "18-96396", "18-96400", "18-96477",
"18-96480", "18-96500", "18-96511", "18-96514", "18-96521", "18-96525",
"18-96577", "18-96592", "18-96613", "18-96617", "18-96621", "18-96624",
"18-96651", "18-96654", "18-96685", "18-96704", "18-96710", "18-96722",
"18-96731", "18-96736", "18-96749", "18-96750", "18-96759", "18-96762",
"18-96768", "18-96787", "18-96789", "18-96799", "18-96834", "18-96886",
"18-96907", "18-97034", "18-97037", "18-97063", "18-97076", "18-97120",
"18-97141", "18-97224", "18-97232", "18-97233-HR", "18-97255",
"18-97296", "18-97321", "18-97331", "18-97341", "18-97345", "18-97349",
"18-97360", "18-97396", "18-97420", "18-97424", "18-97443", "18-97445",
"18-97455", "18-97563", "18-97572", "18-97575", "18-97610", "180089582",
"180089597", "180089602", "180089626", "180089641", "180089642",
"180089643", "180089655", "180089731", "180089985", "180090166",
"180090226", "180090241", "180090253", "180090255", "180090353",
"180090576", "180090623", "180090692", "180090745", "180090827",
"180091123", "180091392", "180091404", "180091405", "180091457",
"180091465", "180091474", "180091512", "180091683", "180091687",
"180091717", "180091725", "180091738", "180091822", "180091829",
"180091963", "180091978", "180091980", "180091996", "180092019",
"180092134", "180092141", "180092223", "180092246", "180092265",
"180092274", "180092277", "180092348", "180092350", "180092354",
"180092355", "180092366", "180092434", "180092437", "180092473",
"180092509", "180092513", "180092549", "180092562", "180092585",
"180092596", "180092624", "180092697", "180092838", "180092840",
"180093062", "180093130", "180093133", "180093155", "180093201",
"180093211", "180093225", "180093368", "180093385", "180093411",
"180093432", "180093441", "180093531", "180093550", "180093598",
"180093618", "180093641", "180093648", "180093649", "180093661",
"180093665", "180093666", "180093681", "180093684", "180093688",
"180093690", "180093744", "180093750", "180093764", "180093766",
"180093767", "180093772", "180093807", "180093814", "180093822",
"180093882", "180093917", "180093938", "180093966", "180093969",
"180093994", "180094000", "180094008", "180094033", "180094051",
"180094144", "180094181", "180094249", "180094278", "180094297",
"180094355", "180094359", "180094382", "180094474", "180094511",
"180094645", "180094709", "180094738", "180094768", "180094795",
"180094806", "180094881", "180094892", "180094965", "180094991",
"180094996", "180095006", "180095129", "180095131", "180095141",
"180095148", "180095170", "180095185", "180095202", "180095216",
"180095221", "180095246", "180095274", "180095278", "180095342",
"180095353", "180095389", "180095405", "180095434", "180095480",
"180095499", "180095502", "180095503", "180095526", "180095550",
"180095569", "180095618", "180095679", "180095688", "180095702",
"180095757", "180095760", "180095761", "180095782", "180095797",
"180095815", "180095829", "180095884", "180095896", "180095906",
"180095920", "180096049", "180096074", "180096095", "180096131",
"180096410", "180096475", "180096490", "180096491", "180096558",
"180096689", "180096727", "180096752", "180096756", "180096776",
"180096893", "180097019", "180097469", "180097673", "18090411",
"18090445", "18092944", "18096969"), class = "factor"), Address = structure(c(410L,
454L, 11L, 28L, 26L, 107L, 272L, 45L, 213L, 234L, 158L, 339L,
454L, 146L, 370L, 264L, 401L, 234L, 144L, 126L), .Label = c("",
"121", "183", "20", "21ST", "22ND", "23RD", "24TH", "25TH", "28 TH",
"28TH", "2ND", "30", "33RD", "4TH", "7TH", "820", "820 EAST",
"820 N FWY", "8TH", "ACADEMY", "AIRPORT", "ALLEN", "ALLIANCE GATEWAY",
"ALSTON", "ALTA MERE", "ALTA MESA", "ALTAMESA", "AMON CARTER",
"ANDERSON", "ANDRESS", "ARBOR", "ARBORLAWN", "ARIEL", "ASH MEADOW",
"AVE H", "AVE N", "AVONDALE HASLET", "AVRIL CT N", "AZLE", "BAILEY BOSWELL",
"BALDWIN", "BALTIMORE", "BASSWOOD", "BEACH", "BELKNAP", "BENBROOK",
"BENBROOK HWY", "BERKE", "BERRY", "BEVERLY", "BIDDISON", "BIRDS EYE",
"BISHOP", "BLEDSOE", "BLUE MOUND", "BOAT CLUB", "BOAZ", "BOMAR",
"BOMBER", "BONDS RANCH", "BONNIE BRAE", "BRENTWOOD STAIR", "BRENTWOOD STAIR RD",
"BRIDGE", "BRIDGEWOOD", "BRYANT IRVIN", "BRYANT IRVIN NORTH",
"BRYANT IRVIN RD N", "BUCKINGHAM", "BUTLER", "CALHOUN", "CALIFORNIA",
"CALMONT", "CAMBRIDGE", "CAMELOT", "CAMERON", "CAMP BOWIE", "CAMP BOWIE WEST",
"CAMPUS", "CAYLOR", "CENTREPORT", "CHAPEL CREEK", "CHERRY", "CHRISTOPHER",
"CLAIREMONT", "CLEBURNE", "CLEVELAND-GIBBS", "CLIFFORD", "CLIFFORD CENTER",
"CLIFFORD CENTER", "COLLEGE", "COLLIN", "COMMERCE", "COOKS",
"COUNTRY CREEK", "CRAIG", "CRAIG EAST LOOP 820 NB", "CRAVENS",
"CRENSHAW", "CROCKETT", "CROMWELL MARINE CREEK", "CROWLEY", "CROWLEY CLEBURNE",
"CROWN OAKS", "CRUMP", "CRYSTAL LAKE", "DAGGETT", "DALTON", "DE COSTA",
"DECATUR", "DEVONSHIRE", "DILLOW", "DILWORTH", "DONNELLY", "DUTCH BRANCH",
"E IH 20", "E LONG AVE", "E LOOP 820 NB", "EAST", "EAST FREEWAY",
"EAST FRWY", "EAST FWY EB", "EAST FWY WB", "EAST LOOP", "EAST LOOP 820",
"EAST LOOP 820 NB SR", "EAST LOOP 820 NORTH", "EAST LOOP 820 NORTH FWY SB",
"EAST LOOP 820 S", "EAST LOOP 820 SOUTH", "EAST LOOP 820 SOUTH FWY NB",
"EAST LOOP 820 SOUTH FWY SB", "EAST LOOP 820 SOUTH N/B", "EAST LOOP 820 SOUTH NB RAMEY",
"EAST LOOP 820 SOUTH SR SB", "EASTCHASE", "EASTCHASE IH 30 EB",
"EDERVILLE", "EDGECLIFF", "EDWARDS RANCH", "EL CAMPO", "ELLIS",
"EPHRIHAM", "ESTRELLA", "EVANS", "EVERMAN", "FAA", "FELIX", "FM 1220",
"FOCH", "FORBES", "FOREST HILL", "FOREST PARK", "FREEWAY", "FRWY",
"FRYE", "FWY", "FWY NB", "FWY SB", "FWY WB", "GAMBRELL", "GARDEN ACRES",
"GARDEN SPRINGS", "GENDY", "GODDARD", "GOLDEN TRIANGLE", "GRAFTON",
"GRANBURY", "GRAND", "GRANITE CREEK", "GRAVEL", "GRAYSON", "GREEN OAKS",
"GREEN RIDGE", "GREENBELT", "GROVE", "HANDLEY", "HANNA RANCH",
"HARMON", "HARMOND", "HARRINGTON", "HEMPHILL", "HENDERSON", "HENSLEY",
"HERITAGE TRACE", "HIGH", "HIGHWAY 114", "HIGHWAY 199 ACCESS",
"HIGHWAY 287", "HIGHWAY 360", "HOUSTON", "HULEN", "HULEN SB",
"HWY 183", "HWY 199 ACCESS", "HWY 287 & 81", "HWY 360", "HWY 360 NB",
"HWY157", "I-20", "I 35 SERVICE ROAD", "I30", "I35", "IH-20 W/B",
"IH 20", "IH 20 EB", "IH 20 EB EAST LOOP 820 SOUTH NB", "IH 20 EB HULEN",
"IH 20 EB IH 35W NB", "IH 20 FWY WB", "IH 20 WB", "IH 20 WB GRANBURY",
"IH 20 WB OAK GROVE", "IH 30", "IH 30 EB US 287 SB", "IH 30 WB EXIT COOKS RAMP",
"IH 30 WB UNIVERSITY", "IH 35W", "IH 35W SB IH 30 EB", "IH 35W SB IH 30 WB",
"IH 35W SB NE LOOP 820 EB", "IH 35W SB RENDON CROWLEY", "IH20",
"IH20 FWY", "IH30 EB US287 SB RAMP", "IH35 SB E 1H30 EB RAMP",
"IM TERRELL", "INDEPENDENCE", "INTERNATIONAL", "INTERNATIONAL SB ST HWY 183 EB",
"INTERSTATE", "J BOAZ", "JACKSBORO", "JAMES", "JAMES AVE", "JANICE",
"JENNINGS", "JESSAMINE", "JIM WRIGHT HWY", "JOHN T WHITE", "JOHN T WHITE RD N",
"JONES", "JUDD", "KELLER HASLET", "KELLER HICKS", "KELLEY", "KING OAKS",
"KINGSWOOD", "KROGER", "LACKLAND", "LANCASTER", "LANCASTER EB US HWY 287 SB",
"LANCASTER WB US 287 NB", "LAS VEGAS", "LEA CREST", "LEE", "LIBBEY",
"LINCOLN", "LISBON", "LITSEY", "LONG", "LOOP", "LOOP 820", "LOOP 820 E/B",
"LOOP 820 EB IH 35W NB", "LOOP 820 EB SR", "LOOP 820 FWY", "LOOP 820 NORTH",
"LOOP 820 S", "LOOP 820 SERVICE ROAD EB", "LOOP 820 SOUTH", "LOOP 820 SOUTH FRWY",
"LOOP 820 SOUTH FWY SB", "LOOP 820 WB", "LOOP 820 WB IH 35W NB",
"LOOP 820/JIM WRIGHT", "LOST CREEK", "LOVING", "LUBBOCK", "MACEO",
"MACON", "MADDOX", "MAIN", "MANSFIELD", "MANSFIELD HWY", "MARINE CREEK",
"MARK IV", "MARTIN", "MARTIN LUTHER KING", "MARTIN LUTHER KING FWY SB SR",
"MAYFAIR", "MC CART", "MCALISTER", "MCCART", "MEACHAM", "MEADOW CREEK",
"MEADOWBROOK", "MERIDA", "MICHAEL", "MILLER", "MINISTER", "MISSISSIPPI",
"MITCHELL", "MLK", "MONARCH", "MONTAGUE", "MONTGOMERY", "MORTON",
"MT VERNON", "MULESHOE", "MULKEY", "N FWY", "NASHVILLE", "NAVADA",
"NECHES", "NELL", "NOKONI", "NOLAN", "NORTH", "NORTH EAST", "NORTH FREEWAY",
"NORTH FREEWAY NB", "NORTH FRWY", "NORTH FWY", "NORTH FWY SR NB",
"NORTH FWY SR SB", "NORTH SOUTH", "NORTH SOUTH FWY SB", "NORTH SOUTH FWY SR NB",
"NORTHEAST LOOP 820", "NORTHEAST LOOP 820 SR EB", "NORTHSIDE",
"NORTHWEST LOOP 820", "NORTHWEST LOOP 820 EB", "NORTHWEST LOOP 820 FWY W",
"NORTHWEST LOOP 820 SR", "NORWOOD", "OAK GROVE", "OAK PARK",
"OAKBEND", "OAKLAND", "OAKMONT", "OAKMONT BLVD", "OLD DECATUR",
"OLD HEMPHILL", "OVERTON RIDGE", "PARIS", "PARKSIDE", "PATE",
"PAVED", "PECAN", "PECOS", "PENNSYLVANIA", "PERKINS", "PERSHING",
"PIPELINE", "PORTLAND", "POST OAK", "POST OAK E", "PRAIRIE",
"PRECINCT LINE", "QUEBEC", "RACE", "RAILHEAD", "RAMEY", "RANDOL CROSSING",
"RANDOL MILL", "RANSOM TER", "RAY WHITE", "RENAISSANCE SQ", "RENDON CROWLEY",
"RENDON CROWLEY IH 35W NB", "RICKENBACKER", "RIDGLEA", "RIDGMAR",
"RIPY", "RISINGER", "RISINGER RD", "RIVER RANCH", "RIVERSIDE",
"ROARING SPRINGS", "ROSEDALE", "RUNNING RIVER", "RUTHERFORD",
"S FWY NB", "S UNIVERSITY", "S US HWY 287", "SAMUELS", "SAN JOAQUIN",
"SANBORN", "SANDY", "SARITA", "SB RAMP", "SCOTS BRIAR", "SCOTT",
"SELKIRK", "SEMINARY", "SH 121", "SHADYDELL", "SHAW", "SILENT HOLLOW",
"SOUTH", "SOUTH EAST", "SOUTH FREEWAY", "SOUTH FWY", "SOUTH FWY NB",
"SOUTH FWY SR SB", "SOUTHEAST LOOP 820", "SOUTHWEST", "SOUTHWEST BLVD SR EB",
"SOUTHWEST BLVD SR WB", "SOUTHWEST FRWY", "SOUTHWEST LOOP", "SOUTHWEST LOOP 820",
"SOUTHWESTLOOP 820", "SOVEREIGN", "SPUR 280", "SPURGEON", "STADIUM",
"STANDISH", "STATE HIGHWAY 360", "STATE HWY 121", "STATE HWY 121 EB",
"STATE HWY 121 WB IH 35W NB", "STATE HWY 183", "STATE HWY 183 EB AMON CARTER",
"STATE HWY 183 EB ST HWY 360 SB", "STATE HWY 183 WB", "STATE HWY 183 WB ST HWY 360 SB",
"STATE HWY 199", "STATE HWY 360", "STATE HWY 360 NB ST HWY 183 EB",
"STATE HWY 360 NB TRINITY RAMP", "STEPHENSON", "SUFFOLK", "SUMMER CREEK",
"SUMMERFIELDS", "SUMMIT", "SUN VALLEY", "SYCAMORE SCHOOL", "SYCAMORE SCHOOL RD",
"SYLVANIA", "TANGER", "TANNER", "TARRANT", "TERRELL", "TEX",
"THROCKMORTON", "TIMBERLAND", "TOM LANDRY", "TRAIL LAKE", "TRAVERTINE",
"TRINITY", "UNIVERSITY", "UNIVERSITY PARK", "US 287", "US 287 SB",
"US HWY 183 WB", "US HWY 287", "US HWY 287 SB", "US HWY 287 SB EAST LOOP 820 SOUTH NB",
"VALKUS", "VAUGHN", "VEL", "VICKERY", "VILLAGE CREEK", "W IH 20 EB",
"W IH 20 FWY EB", "W RENDON CROWLEY", "WAGGONWHEEL", "WALDEN WOOD",
"WALLACE", "WALTON", "WEATHERFORD", "WEBER", "WEDGMONT", "WELCH",
"WESLEYAN", "WEST", "WEST FREEWAY", "WEST FWY", "WEST FWY WB",
"WEST LOOP", "WEST LOOP 820 NORTH SR NB", "WESTCREEK", "WESTDALE",
"WESTERN CENTER", "WESTPORT", "WHITE SETTLEMENT", "WICHITA",
"WILBARGER", "WINIFRED", "WOLF MOUNTAIN", "WONDER", "WOODWAY",
"WORLD WIDE", "Y C SHAMBLEE", "YUCCA"), class = "factor"), On_site = c(FALSE,
TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE),
Date = structure(c(6L, 6L, 4L, 6L, 5L, 6L, 6L, 6L, 5L, 6L,
7L, 8L, 4L, 4L, 6L, 6L, 4L, 6L, 4L, 6L), .Label = c("10/10/2018",
"10/11/2018", "10/12/2018", "10/13/2018", "10/14/2018", "10/15/2018",
"10/16/2018", "10/17/2018", "10/18/2018", "10/19/2018", "10/20/2018",
"10/21/2018", "10/22/2018", "10/23/2018", "10/24/2018", "10/25/2018",
"10/26/2018", "10/27/2018", "10/28/2018", "10/29/2018", "10/3/2018",
"10/30/2018", "10/31/2018", "10/4/2018", "10/5/2018", "10/6/2018",
"10/7/2018", "10/8/2018", "10/9/2018", "11/1/2018"), class = "factor"),
latitude = c(32.7058, 32.80217, 32.79703, 32.65049, 32.7218,
32.85138, 0, 32.76173, 32.67281, 32.78689, 32.68455, 32.63313,
32.80966, 32.70743, 32.92006, 0, 32.70241, 32.78521, 32.78658,
32.68574), longitude = c(-97.43445, -97.16269, -97.37375,
-97.37472, -97.4417, -97.40293, 0, -97.2877, -97.37544, -97.38503,
-97.32159, -97.30425, -97.12623, -97.31852, -97.27253, 0,
-97.31786, -97.38301, -97.3821, -97.2406)), row.names = c(NA,
20L), class = "data.frame")
我知道服务器功能有问题。如果有人能弄清楚那就太好了。
您过滤了日期,但事件$日期格式为 mm/dd/yyyy。所以先进行格式转换。
incident$Date <- as.Date(strptime(incident$Date, format="%m/%d/%Y"))
多余逗号
selectInput("On_site", label = "On site",
choices = unique(incident$On_site))
传单中没有数据,因此不应使用“~”运算符。首先检查数据可用性。
server <- function(input, output) {
# Create map
filtered <- reactive({
req(input$Date, input$On_site)
incident %>%
filter(Date == as.Date(input$Date) & On_site == input$On_site)
})
output$mymap <- renderLeaflet({
leaflet() %>% addTiles() %>%
addProviderTiles(providers$Esri.NatGeoWorldMap) %>%
fitBounds(min(incident$longitude), min(incident$latitude), max(incident$longitude), max(incident$latitude))
})
observe({
req(filtered())
leafletProxy("mymap") %>%
clearShapes()%>%
clearPopups()%>%
clearMarkers()%>%
addMarkers(lat = filtered()$latitude,
lng = filtered()$longitude,
popup = paste0("<strong>", filtered()$incident_number, "</strong><br/>","On_site: ", filtered()$On_site, "<br />")
)
})
#........
}