title: Migrating R libraries
body: <p>I'd like to move several R libraries (*) from one drive to another, on Linux, and would like to know whether a simple move is feasible and safe or if I should uninstall and reinstall the packages.  I realize that the locations of libraries are identified via <code>.libPaths()</code> and have looked through the "R Installation and Administration" manual to find out about migrating libraries, but don't see a recommended process.</p>
  
  <p>I perceive three options:</p>
  
  <ol>
  <li>Run <code>remove.packages()</code> for all of the non-base packages, and install anew via <code>install.packages(lib = "/path/to/new/location")</code>.</li>
  <li>Move the libraries (directories) using <code>mv</code> and use symlinks to point to the new locations (and eventually remove the symlink)</li>
  <li>Use the <code>mv</code> command in Linux to move the directories wholesale and update <code>.Library.site</code> in <code>R_HOME/etc/Rprofile.site</code>, as suggested in the <a href="http://cran.r-project.org/doc/manuals/R-admin.html#Managing-libraries" rel="noreferrer">R Installation and Administration manual</a></li>
  </ol>
  
  <p>Option #1 is blunt.  Option #2 should work, but seems a bit unsound.</p>
  
  <p>Is #3 safe or are there serious problems with it?  The issues I've identified are: directory permissions and the possibility that any package's setup stores absolute paths rather than relative paths (which seems unsound and unnecessary).</p>
  
  <p>Regarding the storage of absolute paths, I found that <code>rJava</code> stores the location of <code>R_HOME</code> in a file called <code>run</code>.  This isn't a library problem <em>per se</em>, but it is one indication of a package (and a good package at that) keeping a private copy of an absolute path.</p>
  
  <p>(*) There are several libraries and many scores of packages.  Naturally, just the libraries (directories) are moved, but packages could be affected.</p>
  
  <hr>
  
  <p>UPDATE 1 / Clarification: Just to clarify: I am <em>only</em> migrating libraries, not changing the version of R or the versions of the packages.  Updating R or the packages may be done separately, but the question is just whether or not moving the libraries is feasible.  It seems that if it is necessary to update or reinstall all packages in order to be sure things are installed correctly, then that is a path more akin to option #1 than option #3.</p>
  
  <p>UPDATE 2: Answers to <a href="https://stackoverflow.com/questions/1401904/painless-way-to-install-a-new-version-of-r">another SO post</a> have some good ideas on how to avoid this problem when upgrading.  I'm not upgrading R, but Dirk Eddelbuettel's suggestion of not installing packages in the filetree of R is wise.</p>