Shiny app works locally but has trouble locating data file when published

... Hi, I am trying to create an RShiny app that uses counties.rds, a dataset of demographic data for each county in the United States that I downloaded from an RShiny tutorial. When I run my app locally it works just fine but when I try to publish the app to shinyapps.io I receive the following error:

I believe the error is because even though my app is able to read the RDS file locally, there is some issue with the app reading the file once I try publishing it.

Below I have included the code that I am using to open the RDS file. I got this path by selecting the .rds file in my directory (genome-analysis) and copying the path that appeared in my console. Right now I have my RShiny App folder labeled census-app (as per the tutorial) and a data folder within the App folder containing the .rds file.

#loading county data and making key
counties <- readRDS("~/genome-analysis/census-app/data/counties.rds")

If anyone has any suggestions on how to resolve this issue, it would be greatly appreciated and I thank you in advance!

You're going to want to have a /data directory within your app project folder. Then you can readRDS("/data/counties.rds") without issue. And this data folder should be within the "app" folder within the project itself, like, "app/data/counties.rds"

1 Like

The Troubleshooting section of the documentation talks about not using absolute paths.

@abhoffman is spot on that you should include the data file in the bundle of the application, and then use a relative path to access it.