R 2.12 to 2.13 package upgrade

If you:

  • use Linux
  • have just upgraded your R installation from 2.12 to 2.13
  • installed some/all of your packages in your home area (e.g. ~/R/i486-pc-linux-gnu-library/2.12) and…
  • …are wondering why R can’t see them any more

just do this:

# at a shell prompt
cp -r ~/R/i486-pc-linux-gnu-library/2.12 ~/R/i486-pc-linux-gnu-library/2.13
# in R console
update.packages(checkBuilt=TRUE, ask=FALSE)
# back to the shell
rm -rf ~/R/i486-pc-linux-gnu-library/2.12

update: corrected a typo; of course you need “cp -r”

9 thoughts on “R 2.12 to 2.13 package upgrade

  1. Pingback: How to upgrade R on windows 7 | R-statistics blog

  2. Put the first command into the Ubuntu terminal. Then opened RStudio and typed the second command you specified into console. It comes back with the following error:

    > update.packages(checkBuilt=TRUE, ask=FALSE)

    Warning in install.packages(update[instlib == l, “Package”], l, contriburl = contriburl, :
    ‘lib = “/usr/lib/R/library”‘ is not writable
    Error in install.packages(update[instlib == l, “Package”], l, contriburl = contriburl, :
    unable to install packages

    • The error occurs because you have to be the root user to install packages in /usr/lib/R. The procedure that I outlined applies only for packages in your home directory ($HOME/R). If you don’t have packages in that location, you don’t have to worry about upgrading. If you have some packages in $HOME/R and some in /usr/lib/R, you don’t have to worry about the error: the procedure will upgrade those in $HOME/R and leave the others alone.

      If you want to write to packages in /usr/lib/R, you need to start R as root (“sudo R”).

  3. If I look in HOME/R, I see a folder i486-pc-linux-gnu-library. If open that folder, I see three folders 2.10, 2.12, 2.13. I see folders inside the 2.12 folder with the names of all the packages I am looking for. If I open the 2.13 folder, it’s empty. I also went to /usr/lib/R and didn’t see any of the packages I’m missing.

    Based on your comment that the procedure will upgrade the packages in R/HOME, I went into RStudio console and tried a require command and got the following error

    > require(quantmod)
    Loading required package: quantmod
    Warning message:
    In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
    there is no package called ‘quantmod’

    Any suggestions on what I should do now ?

    • If the 2.13 directory is empty, then you have not successfully copied the contents of 2.12/ to 2.13/, as per the first line of the upgrade procedure. Which, I notice from my instructions is my fault! The correct command is “cp -r”, not just “cp”.

      So basically, just make sure everything inside 2.12/ is copied to 2.13/, then try again.

  4. During the initial process, I executed the 3rd line of your code. I looks like that wiped out the 2.12. folder. Is there anything I can do other than just start installing each package again ?

    • Nope. Installation from scratch is now the only way, I’m afraid. You need to be careful with “rm -rf”, it’s not very forgiving :-)

  5. Sorry it didn’t work out. But thanks very much for walking me through and the fast response.

Comments are closed.