This repository demonstrates a pattern for managing project-specific development scripts in R by creating a nested development package inside your main application package.
For more background, rationale, and detailed examples, see my blog post: A More Customizable Golem: Nested Development Packages in R
The repo includes two example projects:
-
Minimal setup --
myapp/myapp.Rproj
-
renv-based setup --
myapp-renv/myapp.Rproj
-
Clone the repo and open
myapp/myapp.Rproj
in RStudio or Positron. -
On project load, you should see:
ℹ Loading myapp.dev
-
If
pkgload
is not installed, you'll see a warning. Install it and restart your session. -
Once loaded, you can call development functions like:
myapp.dev::run()
myapp.dev::deploy()
The myapp-renv
project shows how to integrate renv with a dev package:
-
Clone the repo and open
myapp-renv/myapp.Rproj
in RStudio or Positron. -
Run
renv::restore()
to synchronize all package versions. -
Restart your session to have
myapp.dev
loaded in a controlled environment.
-
The dev package should not be included in production deployments.
-
A common approach: clone a fresh repo, snapshot dependencies excluding dev, and deploy using
rsconnect::deployApp()
. (Seemyapp-renv/dev/R/deploy.R
for an example)
-
Remember to restart your R session after updating the dev package.
-
Update the
NAMESPACE
of your dev package withdevtools::document("dev")
when changing exports. -
For a full discussion and detailed rationale, see the blog post.