-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an R package #2
Comments
Another, major, advantage with having a self-contained R package is that it will be much much ... much easier for you to update the app that will be deployed on the ShinyProxy server. In that case, all that will be required will be to rebuild the Docker container (which should be fully automatic) and re-deploy on the server (also automatic). |
Okay, thanks for figuring out these steps. I will make it tomorrow (I've made one before a few years ago, so it should be a nice review). Will update here with any qs or once done. |
Quick question - I originally had (for the non packaged version of this) all of my data organized in nested subdirectories. For R packages I've made in the past, I had always had my data in .rda files directly in /data. Is it valid to keep this original nested subdirectory structure in /data? Or will I need to get all of my individual data files out of these subdirectories and have them directly in /data? Thanks! |
It is ok to use whatever nested folder structures you'd like. However, you must not put in a folder named
Instead, I recommend that your put your existing root <- system.file(package = "GliomaAtlas3D", "exdata") and specific subfolders as: path <- system.file(package = "GliomaAtlas3D", "exdata", "datasets")
path <- system.file(package = "GliomaAtlas3D", "exdata", "datasets", "Patient260")
... or if you prefer: root <- system.file(package = "GliomaAtlas3D", "exdata")
path <- file.path(root, "datasets")
path <- file.path(root, "datasets", "Patient260")
... You could of course also skip the root <- system.file(package = "GliomaAtlas3D") above. |
FYI, and we don't have to do this already now, but if you imagine that there might be other data sets/samples in the future, you could also create a standalone dataset package that only holds the data, e.g. |
Not sure - I typically end up with trial'n'error in these cases. But, yes, |
This worked beautifully, thank you. |
Alright I finally figured out from trial'n'error how to get this to work. For future ref just in case someone else asks, I ended up having to create a new resource path so shiny could find it: addResourcePath('www', system.file('shinyApp/www', package = 'GliomaAtlas3D')) and then to use an object from it, reference this resource name: img(src= 'www/image1.png') |
Great idea, definitely could be a handy thing to have as it sounds like we will be adding different datatypes in the future from our lab. Thanks! |
Final new package is in https://github.com/SRHilz/GliomaAtlas3D/ |
I propose that you create an R package named
ThreeDGliomaAtlas
that serves your function. The advantage is that all package dependencies will be installed automatically, there is no need forsource()
in the Shiny app - just alibrary(ThreeDGliomaAtlas)
. When there is a first working R package, we can then automatically check it withR CMD check
which is an awesome tool for catching current mistakes but also future ones (you can have GitHub Actions to run these check every time you push and you'll be notified if you made a mistake).The gist is:
Create a
DESCRIPTION
file that specifies the name of the package, has a short description and that specify all package dependencies that your app needs.Move your
scripts/**/*.R
files toR/*.R
Run
devtools::install()
. Tweak what needs to be tweaked, and repeat.If you haven't done an R package or struggle, then I can help you. For me, it's pretty straightforward to do but if you want to learn, this is a great opportunity.
When the above is in place, the next step is to also move in the data files into the R package. Hosting data is something R packages do well too. Then, one can move in also the Shiny app into the package. At this point, you will have your Shiny app/artifact fully contained in a single R package. This is where you can consider submitting it to CRAN and have it archived there until the end of time.
The text was updated successfully, but these errors were encountered: