I am using system.file() in my Shiny application, which is also a package. The file in question is located in /inst/database/db.sqlite
system.file("database", "db.sqlite", package = "MyPackage") does not work
system.file("inst/database", "db.sqlite", package = "MyPackage") works
Could anyone explain what might be happening here. I was under the assumption that while inside a Shiny app, system.file would find the file given the subdirectory within /inst.
...
I understand the situation better now. When I click the "Source" button in RStudio, this sets the working directory to the location of the script file which affects how functions like system.file() resolve file paths.
R Studio sets the working directory to the directory containing the script being sourced
Any file paths or relative paths used within the script are resolved relative to the current working directory.