I have written a shiny app and a filter for selecting a determined input. I have always used this code and usually it's works but this time I have a problem. If I delete this row: Legend <- Legend %>% filter(Legend$col1 == input$magazzino) the shiny app works but obviously the filter does not. Also If I run the code without run before Legend if I have another error. I don't understand where I am wrong.
shinyServer(
function(input, output, session) {
dati1 <- c("a - Novara Delete", "b - Torino Trash", "c - Milano", "f - Bari")
prov_ita <- rgdal::readOGR("https://raw.githubusercontent.com/openpolis/geojson-italy/master/geojson/limits_IT_provinces.geojson")
Legend <- tidyr::separate(data.frame(dati1), col = dati1, into = str_c("col", 1:2), extra = 'drop')
#filter
magazzino <- reactive({
filter(Legend, col1 == input$magazzino)
})
observeEvent(input$magazzino,{
points <- eventReactive(input$recalc, {
cbind(rnorm(40) * 2 + 13, rnorm(40) + 48)
}, ignoreNULL = FALSE)
Legend <- Legend %>% filter(Legend$col1 == input$magazzino)
citta_new <- geocode_OSM(unique(Legend$col2))
citta_new <- merge(citta_new, Legend, by.x="query", by.y="col2")
citta.sf <- arrange(citta_new %>% st_as_sf(coords = c("lon", "lat"), crs = 4326))
output$mymap <- renderLeaflet({
leaflet(prov_ita) %>% addTiles() %>%
addMarkers(data = citta.sf, label = (citta_new$query))
})
})
})
library(shiny)
library(leaflet)
library(tmaptools)
library(sf)
library(leaflet)
library(readxl)
library(dplyr)
library(DT)
library(ggplot2)
library(readxl)
library(stringr)
shinyUI (fluidPage(
navbarPage("My Application",
tabPanel("Magazzino di Partenza",
selectInput("magazzino", "Magazzino di Partenza", choices = unique(Legend$col1)),
leafletOutput("mymap"),
p()
)
)
)
)