Error in Cannot Open some file that doesn't seem to exist when I deploy to shinyapps.io

I've been trying to push my file to my shinyapps.io site. The markdown file is successfully deployed, but there is an error/my website doesn't show up. I opened my log file there it says:

Warning: Error in : Cannot open "C:\Users\XXXXXXXXXX\monkeypox-mapped\countries sf\World_Countries__Generalized_.shp"; The file doesn't seem to exist.

I'm attaching my code for reference:

---
title: "Monkeypox World Dashboard"
output:
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
  runtime: shiny
resource_files:
- countries sf/World_Countries__Generalized_.shp
- countries sf/World_Countries_(Generalized).xml
- countries sf/World_Countries__Generalized_.cpg
- countries sf/World_Countries__Generalized_.dbf
- countries sf/World_Countries__Generalized_.prj
- countries sf/World_Countries__Generalized_.shx
---

```{r setup, include=FALSE}
library(flexdashboard)
library(dplyr)
library(readr)
library(tidyr)
library(ggplot2)
library(plotly)
library(tmap)
library(sf)
library(leaflet)
library(rsconnect)
mpx_country_case_dat_v2 <- read_csv("exported data/mpx_country_case_dat_v2.csv")
mpx_gbl_hospitalizations <- read_csv("exported data/mpx_gbl_hospitalizations.csv")
# import shapefile
world_shp <- sf::st_read("C:\\Users\\Cindy Pang\\monkeypox-mapped\\countries sf\\World_Countries__Generalized_.shp")

# sort country case date to latest 
mpx_global_latest <- mpx_country_case_dat_v2 %>%
  group_by(Country)%>%
  filter(Date_confirmation == max(Date_confirmation), Country != "World")%>%
  select(Country, Date_confirmation, cumulative_confirmed, cumulative_confirmed_suspected, cumulative_confirmed_per_1M, cumulative_confirmed_suspected_per_1M)

mpx_global_map <- merge(world_shp,
                        mpx_global_latest,
                        by.x = "COUNTRY", 
                        by.y = "Country", 
                        all = FALSE)


mpx_world <- mpx_country_case_dat_v2 %>%
  filter(Date_confirmation == max(Date_confirmation), Country == "World")
today_cumulative_confirmed = mpx_world$cumulative_confirmed[1]
today_cumulative_suspected = mpx_world$cumulative_suspected[1]
today_cumulative_confirmed_suspected = mpx_world$cumulative_confirmed_suspected[1]

Row

Cumulative Confirmed Cases

valueBox(today_cumulative_confirmed)

Cumulative Suspected Cases

valueBox(today_cumulative_suspected)

Cumulative Confirmed and Suspected Cases

valueBox(today_cumulative_confirmed_suspected)

Row { .tabset}

Cumulative Confirmed Cases

tmap_mode("view")
map1 <- tm_shape(mpx_global_map)+
  tm_polygons(col = "cumulative_confirmed")

map1

Cumulative Cases & Suspected


tmap_mode("view")
tm_shape(mpx_global_map)+
  tm_polygons(col = "cumulative_confirmed_suspected")

Cumulative Confirmed per Million

tmap_mode("view")
tm_shape(mpx_global_map)+
  tm_polygons(col = "cumulative_confirmed_per_1M")

Cumulative Confirmed & Suspected per Million

tmap_mode("view")
tm_shape(mpx_global_map)+
  tm_polygons(col = "cumulative_confirmed_suspected_per_1M")

Row {.tabset}

mpx_world_ts <- mpx_country_case_dat_v2 %>%
  filter(Country == "World")

Cumulative Case Trend

plot_ly(mpx_world_ts, x = ~Date_confirmation, y = ~cumulative_confirmed, type = "scatter", mode = "lines", name = 'Cumulative Confirmed') %>%
  add_trace(y = ~cumulative_suspected, mode = 'lines', name = 'Cumulative Suspected')%>%
  add_trace(y = ~cumulative_confirmed_suspected, mode = "lines", name = "Cummulative Confirmed and Suspected")%>%
  layout(xaxis = list(title = "Date"), yaxis = list(title = "Cumulative Count"))

World Daily Trend

plot_ly(mpx_world_ts, x = ~Date_confirmation, y = ~confirmed, type = 'bar', name = 'Confirmed')%>%
  add_trace(y = ~suspected, name = 'Suspected')%>%
  layout(xaxis = list(title = 'Date'), yaxis = list(title = 'Daily Count'), barmode = 'stack')%>%
  add_trace(y = ~daily_confirmed_suspected_07d, type = "scatter", mode = 'lines', name = "7-day Rolling Average: Confirmed + Suspected")%>%
  add_trace(y = ~daily_confirmed_07d, type = "scatter", mode = 'lines', name = "7-day Rolling Average: Confirmed, only")

What do I do?

You can't use absolute paths in shiny apps, that specific path doesn't exists in the server the app is going to be running on, all paths must be relative to the app's root folder.

1 Like

This worked!!! Thank you so so so so much!