34

Possible Duplicate:
Painless way to install a new version of R?

In R, packages are not compatible across upgrades, and must be reinstalled. Is there any way to easily install the same set of packages in the new version as what I had installed in the old version?

Edit: I can't easily access the old version of R, since I upgrade via apt.

Community
  • 1
  • 1
Ryan C. Thompson
  • 40,856
  • 28
  • 97
  • 159
  • 2
    Sort of a dupe, but I don't have access to the old version of R, since I upgraded via apt. So the solution there won't work for me, unless I can track the new R into using the old libraries long enough to get the list. – Ryan C. Thompson Oct 20 '10 at 03:38
  • The answers there are all valid. If you can't access the old library directory, then you can't copy your old packages to the new R version. Seems logic to me. For what it's worth, I added a answer there that could prevent you from having this problem. In any case, if you still have access to the old library folder, just set that one in : installed.packages(lib.loc="path/to/folder") – Joris Meys Oct 20 '10 at 11:23
  • I figured out that the new version of R could use the lib.loc option the list the packages that were installed in the old version. So that means that you're right, the answers in the other question worked for me. – Ryan C. Thompson Oct 21 '10 at 05:26

1 Answers1

56

I just posted a question with a possible solution:

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

What about that doesn't work for you?

Joshua Ulrich
  • 173,410
  • 32
  • 338
  • 418
  • 8
    Does this need the libs folder to be copied from the old location to new? – Avinash Jun 24 '14 at 09:03
  • 1
    @Avinash Yes, that was my experience. I copied over/pointed to my existing libs (I just added a personal Rlibs folder in my home directory) that were built under the previous R version and got all the messages about needing to reinstall the packages. I ran the code above and that solved the problem. – Whalen Aug 30 '18 at 15:00
  • which directory should this be in? I have a local directory on my home drive, and also one that is /usr/local/lib/site-library. where should I run this? – sophie-germain Aug 27 '20 at 22:52
  • 1
    /usr/local/lib/site-library/ is where the OS' package manager stores packages. You likely will not be able to install packages there from R under your user account. I had a lot of trouble with this when upgrading from 3.6.3 to 4.0.2 because the binaries were not compatible. So I had to get a list of installed packages, remove them, update the PPA to point to Rutter's R-4.0 binaries, then reinstall the packages. It was quite a pain. Especially because it took me some time to figure out what the problem was. All that said, you can run `update.packages()` on your /home library. – Joshua Ulrich Aug 28 '20 at 14:34
  • It does not work – Julien Jun 28 '22 at 22:50