Within the context of a package, there are tools to make sure that you are using a particular version of package imports, but are there tools to be more specific about this in a script? E.g.:
library("glue (>=1.3.0)") or assert_library(c("glue" = ">=1.3.0", "dplyr" = "github::tidyverse/dplyr@release")
Within packages and installation tools, there are ways to be specific about versions. But in many contexts in R, the relevant unit is a script or code chunk alone, so it seems like it could be helpful to have the option of specificity within the script itself (as opposed to within a separate DESCRIPTION or packrat lockfile). Examples would be reprexes, background jobs in RStudio 1.2, or make builds.
In discussions around reproducible research, there are different 'layers of reproducibility' approaches:
- Put your script inside a package, and use DESCRIPTION to specify versions
packratto store the source code for the packages you use
- Use docker to also store system dependencies
But these all use external files, and script itself still just says
library(pkg). Do approaches exist to be specific about package versions within a script?