Updating R and With Current Libraries

If you work in R for very long on mac, there comes a time when you upgrade and the framework process looses all your libraries!  In some sense this is pretty lame because you now have to install all these libraries again.  However, it can be a blessing if you install packages in a willy-nilly fashion as you will only reinstall the ones you use most often.  At any rate, it is kind of a pain.  Here is what I’ve been doing about this to automate the process.  The key here is that you need to do the first part before you upgrade.

Current Library

In the old version of R, prior to updating you’ll want to save the libraries that you have installed.  In R, this can be done as follows:


Install Updated R Version

Either download the latest package or update your svn repository and rebuild R and install it.  There are a lot of options for learning more about these options elsewhere on the web.

Install Missing Packages

Now, in the new version of R, you can figure out which are installed by default and then take the differences from what you have and what the previous version had installed and then install them.


And you should be done.

Compiling r-devel

There are several reasons why, as someone that contributes packages to R, that you should consider using r-devel instead of the latest release.  Primary among these reasons are the fact that there may be changes in r-devel that are not in the latest release version and the maintainers will ding you for not using the correct version.  For whatever reason, it is a good idea and here are the notes I’ve put together to compile it on OSX (at the time this was written I was using 10.8.3).


First among the requirements is the OS X development environment.  This includes all the compilers and associated tools you’ll need.  You can get these directly from Apple through the App Store.

You will also need:

  1. Subversion.  This is some very useful software for source code development and collaboration.  This can be installed once you install the XCode stuff from Apple.  svn is part of the ‘command line tools’ that the package provides.  However, it is not automatically installed, you’ll have to do it after installing XCode directly.
  2. gfortran-4.2X.  This is found on the R webpage.  Go to the Mac download and then the ‘tools’ directory.  Download and install it.


Here is the general approach I used, that seemed to work.

  1. Grab the latest version of r-devel.It should be noted that there is currently no certificate for this, so you’ll have to believe that there is no malicious code in the bundle.
  2. Grab the recommended packages that are not part of the r-devel distribution (you’ll need these or things will go pear shaped).
  3. If you are using OSX Mavericks, you may need to install the command line tools first (this only needs to be done once).  Type this:
  4. Configure the compilation.  I just grabbed these options from the default ones the binary OSX version uses.
  5. Make the base packages
  6. Check the compilation for any potential errors.
  7. Make the vignettes
  8. Make the manuals (an optional part here but if you are going to go through all this, you might as well do it completely).  I compile them as PDF.
  9. Install it


One of the benefits of having a svn repository locally is that you can just update it the next time that you need it and rebuild the components that have changed.  To update the repository simply issue the following command in the directory with the r-devel folder.

Then you can rebuild as outlined above.