r-docker-renv: recreating the r-docker environment (essentially on Windows but in theory on Intel Macs and x86_64 Linux as well)
This repo recreates the r-docker environment on your local installation of R.
Only the package versions and version of R will be the same. The operating system and architecture may be different, hence you may see some very small differences in results.
-
Install R 4.0.5 for Windows, installer here
-
Install Rtools 4.0 from here
-
Open RStudio using R 4.0.5 by holding Ctrl when you clicking the RStudio icon. This will show the RStudio R version selection window
-
Open this project in that RStudio running R 4.0.5, by clicking File | Open Project...
-
Run setup.R (technically we should just be able to run
renv::restore(prompt = FALSE)
but some hackery is needed for a few packages first)source('setup.R')
-
Run restore.R or
renv::restore(prompt = FALSE)
-
Here's proof that this ran successfully on Windows
-
A warning you can ignore: After successfully running the restore if you run
renv::status()
it will report the following.renv::status() #> The following package(s) do not appear to be used in this project: #> _ #> BH [1.72.0-3] #>... (I deleted alot of output here) #> zoo [1.8-8] #> #> Use `renv::snapshot()` to remove them from the lockfile.
You can ignore the advice to remove the packages because all this means is that there is no .R/.Rmd/.qmd script/s in the project that uses the all of the packages.
-
To do some work in an OS project, change the working directory to that of your OS project using
setwd()
, and use RStudio's menus, e.g., File | Open File..., to open/create/modify/save R scripts as usual.
-
macOS users should install Xcode developer tools by issuing in the Terminal
xcode-select --install
-
A Fortran compiler is required to be installed in the location R is expecting (note that the version from Homebrew will not work).
-
Install R 4.0.5 using the relevant installer or use
rig
-
R installer for macOS
- Intel processor, here
- Apple processor - I don't think R 4.0.5 was released for Apple Silicon, so run the Intel version above (it will automatically run under rosetta2)
-
rig https://github.com/r-lib/rig#readme, first install Homebrew, then install
rig
brew tap r-lib/rig brew install --cask rig
-
(Only works on Windows and Intel Macs) Install R 4.0.5
rig add 4.0.5
-
-
On macOS launch the Rig.app menu bar app which will now be in your Applications directory
-
On Apple Silicon Macs run
rig system make-orthogonal
-
Use the Rig.app menu bar app to launch RStudio under R 4.0.5 as follows
-
Open this project, e.g., by double-clicking the renv-r-docker.Rproj file
-
Run setup.R (again we should just be able to run
renv::restore(prompt = FALSE)
but some hackery is required for a few packages)source('setup.R')
-
Run restore.R or
renv::restore(prompt = FALSE)
-
Update the renv.lock file by running in a Bash shell
./fetch.sh
-
Then run
renv::restore(prompt = FALSE)
-
If this fails try upgrading renv first, i.e.,
renv::upgrade(prompt = FALSE) renv::activate() renv::restore(prompt = FALSE)