ken
ken

Reputation: 335

Proper location of data directory in shinyapps.io web app

I'm attempted to deploy my first app on shinyapps.io. In the app, the user selects a file from a drop down menu, and the data file is plotted. I am confused where to put the data directory so that the app can access it; I keep getting the "ERROR: Cannot change working directory" message.

My directory is like so: server.R, ui.R and data directory (called MyData) are located in /MyShinyApp. When I deploy the app using deployApp() (which works fine), a directory called shinyapps is created in /MyShinyApp, which contains a subdirectory /MyUsername which contains a MyShinyApp.dcf file. I am using the follow relative path to tell the app where my data is: setwd("./MyData"), but have also tried setwd("../MyData") and setwd(".../MyData") but they don't work either.

Any suggestions on where to move the MyData directory so that my app can access it? Thanks in advance.

Upvotes: 2

Views: 4684

Answers (1)

ken
ken

Reputation: 335

After searching the showLogs() for my app, I was able to figure out what was going on. My data directory was in the right location, and it was being uploaded to the server, but for some reason using relative file paths to change the working directory was not work for me.

Using the absolute file path setwd("/srv/shiny-server/MyShinyApp/MyData") worked, but relative filepath setwd("./MyData") did not work. Its a little strange because when I run deployApp(), the function warnings me that I'm using absolute paths, and I should use relative file paths instead. Not sure if this is a bug or not.

Upvotes: 2

Related Questions