I've just installed the R 3.5 version and need to access all the hundreds of packages I currently have in the 3.4 folder
RStudio suggests
"On most single-user systems (Mac, Windows, and Linux), when you upgrade to a new minor version of R (like 3.3.0 to 3.4.0), R will not find the packages, you will need to reinstall your R packages. This is an inconvenience, but the problem is obvious and it is easy to fix. If you are using a system like this, you can just reinstall your packages after upgrading R. "
That sounds fine if you have one or two packages but is there a quick script that can automate this process for large numbers?
Or is there some package that I could use with the prior version of R to facilitate?
Also can someone also explain what is the issue with just copy and pasting the folders from the file system - which is obviously the quickest method
Copy-paste will (I think) work in most cases. But some packages need to be recompiled for the new R version and you can't avoid re-installing them. This last release necessitates a lot of this.
Thanks
So I can copy and paste and then will just get an error when loading a library I need to recompile? It's all solo work so that would not be an issue
What is the danger of copy-pasting packages to a new library location?
For individual work, the risk of doing this is quite low. As already mentioned, some packages will need recompilation due to the internal changes in R-3.5.0. This may lead to runtime errors - so this is the risk you take.
But one strategy is to copy-paste, then run
update.packages(ask = FALSE)
Your second question is:
How can I script the installation of all my packages?
Try something like this, where lib_loc points to the library of your previous release of R
As @mishabalyasin suggested you can use installr package.
You have:
updateR function which updates R runtime to a new version and also its packages, but I believe this is not your case.
The function copy.packages.between.libraries to copy files from the old library to the new one. And it doesn't copy fundamental packages as MASS, methods, utils, ...
This will update all the packages in this shared library location, which is perfect if you're only running R-3.5.0, but may cause problems if you ever want to run code on older versions of R.
If you're the only user, and this is not production code, this practise is probably fine.
But if you are running code in a shared environment, or a production environment, then do make sure you follow robust practise when updating R versions.
I define two vectors in my .Rprofile, .cran_packages and .gh_packages (prefixed with . so they're hidden in the global environment), and keep a reasonably updated set of what I actually care about. Reinstalling takes a while, but I find it a better solution than copying/linking directories or messing with .libPaths, because if I decide I don't really need a package and take it off my lists, the next time its otherwise-unused dependencies will also disappear, unlike if I just directly remove it.