provides workflow for updating R packages and maintaining a miniCRAN repository in an offline server environment
In a corporate IT environment handling R and R package updates can be tricky. Usually R packages are installed into the user's HOME
directory while standard library packages can be found inside the R installation's library
directory. These paths can be accessed
via .libPaths()
. The R isntallation itself can usually be found under ./Program Files
When updating to a new R version only the packages inside the library
directory of the R installation will be replaced while all
packages inside the HOME
directory remain unchanged. Usually after installing a new version of R we will also update all packages
using update.packages()
.
HOME
and the ./Program Files
directories for IT security reasonsHOME
directory and install R to a local drive outside ./Program Files
. You can setup up R to
only install into the R installation's library
directory by adding libPaths( <path> )
to the Rprofile.site file inside the etc
folder
of the R installation's parent directory.miniCRAN
package to create a local CRAN repository on a machine with online connection which we can then copy
to the server.packrat
or checkpoint
they will save all packages for a certain analysis on disk. This approach
uses up a lot of disk space and can be quite slow. Another approach could be to use a docker
image. What I find more practible is
to create a snapshot everytime R is updated to a new version, which is approximately 4 times a year. Before installing the new version
we simply archive the old R version and the old version of the miniCRAN and note in each analysis folder which R version was used.
If R code is not running anymore on the current version we can simply spin up the old one with which the analysis was orignally performed.
This is not a 100% fool-proofed like saving all packages to disk for each analysis but is more disk space friendly.This workflow requires a lot of copy and pasting of files and it is easy to make mistakes.
running update.packages()
, packages that are explicitly or implicitly loaded will fail to update and then be removed from the current library. There are a number of important packages which are always loaded when Rstudio is running like Rccp
, rlang
to just name a few. Also another R Session running will cause problems.
Each of the steps that are needed to update to a new version takes quite a long time which makes it easy to forget on which step of the sequence one currently is.
updateR
updateR
is MS Windows onlyHOME
directoryRstudio
to run any of the updateR
functions<R installation path>/bin/<x64 or i386>/Rgui.exe
instead.update R will perform a number of sequential steps for you with numerous checks and controls so everything goes smoothly and as fast as possible.
Note all of these function will aks you for some user input - Select new and old R installation folder - Select whether you are on a server or desktop - Select whether you are using miniCRAN on the desktop
run in old R Version
If you do not have a miniCRAN yet make one.
updateR::create_miniCRAN( path = "c:/miniCRAN" )
run in old R Version
updateR::update_from_old_inst()
run in old R Version
updateR::update_from_old_inst()
run in new R Version
updateR::update_new_inst()
Before you transfer make sure that you ran updateR::update_new_inst()
on server first and check if you can find the archived miniCRAN version on disk.
Note this is the only step where you can make a mistake. You will end up with one archived miniCRAN less
This step is important for updating the packages on the server and installing new packages.
run in new R Version
updateR::update_new_inst()
When prompted to select the directories of the R installations simply select the most recent installation twice.
install.packages
updateR::update_new_inst()
on desktopupdateR::update_new_inst()
on serverNote, I would not archive the miniCRAN between R releases, you can however do so manually updateR::update_from_old_inst()
will not work if there is alrady an archive named after the current R Version.
updateR
only uses base R and miniCRAN
functionsupdateR
does not regularly import miniCRAN
because miniCRAN
implicitly loads igraph
which then can fail to update properly. We therefore load miniCRAN
via require('miniCRAN')
and then unload the package via detach( 'package:miniCRAN', unload = T)
updateR
to produce warnings during package checkingAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.