I'm wondering what the best practice is for developing Shiny apps in conjunction with R projects.
I have a large R project, within which I'm trying to make some test Shiny apps. Basic folder structure looks like this:
myproject/ # home directory
├── myproject.Rproj # Overarching R project
├── shiny_apps/
| └── app_1/ # app root directory
| └── app.R # app file
└── scripts/
└── example_script.R # an R script that does something unrelated to the Shiny app
In the rest of my project, I set all my file paths relative to the root directory, "myproject/", either using the here
package or just by specifying relative paths.
I understand that when you run a Shiny app, it understands all filepaths within it as relative to the directory where app.R is located. So e.g. if I need to load in data or source a script, I should write the filepath relative to app_1/ in order to allow the app to run properly.
However, when I'm working on the app interactively, testing things out, running code line by line, etc. (before running the app), those relative file paths don't work. Because I'm working inside of an R project, the paths get interpreted relative to myproject/, since that's the directory where the .Rproj file is located.
I think there must be a best practice for this that I'm not aware of. Am I wrong to try to create Shiny apps inside of an existing R project? Do I need to create a separate R project for each Shiny app, if I want to stick with a project-based workflow? Or is there some known workaround that's recommended for interactive Shiny development w/r/t projects?
Thank you!