rshiny app working but not giving the output when deplyoed in shinyapps.io and but works fine locally

hello I am building a r shiny app and it works well when I use it locally but doesnot work when I deploy it.
i am new here.

here is my code:
library(shiny)
library(readr)
library(leaflet)
library(tmaptools)
library(dplyr)
library(tidygeocoder)
library(sf)
library(DT)

Load the CSV file from a URL

data <- read_csv("https://drive.google.com/uc?export=download&id=1dbw7P47-Wv0EqVPawIJFmnTtwXkUYKDs")
vendors<- read_csv("https://drive.google.com/uc?export=download&id=1s70gtfLOajwbDxnv8AvowKXWyQ5prL0i")
ui <- fluidPage(
titlePanel("School Details and Map"),
sidebarLayout(
sidebarPanel(
selectInput("city", "Select City", choices = unique(data$City)),
selectInput(inputId = "school_name", label = "Select a School Name:", choices = NULL)
),
mainPanel(
fluidRow(
column(width = 12,
verbatimTextOutput("invalid_address")
)
),
fluidRow(
column(width = 12,
leafletOutput(outputId = "map")
)
),
fluidRow(
column(width = 12,
dataTableOutput("vendor_table")
)
)
)
)
)

server <- function(input, output, session) {
a4=observe({
schools_in_selected_city <- data[data$City == input$city, ]
updateSelectInput(session, "school_name", choices = schools_in_selected_city$School Name)

})
hg=reactiveVal()

output$map <- renderLeaflet({
selected_address <- data[data$School Name == input$school_name, ]
address <- selected_address
vendor<-vendors[vendors$City == input$city, ]

location <- address%>%
  geocode(`Complete Address`)

l1 <- location %>%
  filter(!is.na(lat))
location1<-vendor%>%
  geocode(`Full Address`)

l <- location1 %>%
  filter(!is.na(lat))

if (!is.null(location)) {
  a=st_as_sf(l1, coords=c("long","lat"),crs=4326)
  b=st_buffer(a,dist = 8000)
  c=st_as_sf(l, coords=c("long","lat"),crs=st_crs(b))
  
  vendors_inside=st_intersection(c,b)
  hg(vendors_inside)
  map <- leaflet() %>%
    addTiles() %>%
    addMarkers(data=a, popup = input$school_name) %>%
    addCircles(data=a, radius = 8000) %>%
    addCircles(data=vendors_inside,popup=vendors_inside$Store.Name)
  return(map)
}

})
output$vendor_table <- renderDataTable({
# Access the sf dataset from the reactiveValues object
gh=hg()
selected_cols <- c("Store.Name", "Full.Address","School.Name",'Complete.Address',"City","Contact.details","Principal.Name") # Replace with your column names
datatable(gh[, selected_cols], options = list(pageLength = 30))
# Display the first few rows of the spatial data as a table
})
}

shinyApp(ui = ui, server = server)

so do chose the city as brampton you will find the thing I want to achieve at first it might show error due to geocoding problem but it you choose brampton the geocoding works fine.

Hi, I also had issues this morning deploying my shiny app to shinyapps.io. Can you check that your rsconnect package is up to date? It should be version 1.0.1 and above.

See https://forum.posit.co/t/notice-posit-cloud-shinyapps-io-dropping-support-for-rsconnect-1-0-1/172078 for more details.

also here is the link to the deplyoed version:
https://chalise.shinyapps.io/for_deplyoment1/

also when you select the city brampton do select the school as father francis mcspiritt catholic elementery school the code do takes time to run as it does geocoding.

hello flick,
thank you for the reply but I don't think this is the error it works when deplyoed but doesnot give the output as desired or output when I do it locally

1 Like