Using R 4.1.0 and R 4.0.5 on MacOS using RSwitch
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Lately R version 4.1.0 was released on CRAN (see https://cran.r-project.org).
The MacOS version was one day late. But yesterday it was released, too. So I wanted to test the new version without being able to go back. “No problem”, I thought “I’m already using RSwitch”. RSwitch is a tiny Mac program which allows you to switch between installed R versions.
But unfornately RSwitch told me that R version 4.0.5 was incomplete after I’ve installed version 4.1.0.
What’s going on?
I took a look at /Library/Frameworks/R.framework/Versions
where
the different R versions are installed. And indeed in the directory 4.0
most
of the files and symbolic where missing.
I installed version 4.0.5 and the same happened to version 4.1.0 – but I could use version 4.0.5 again.
My Solution
So I backed up the directory under /Library/Frameworks/R.framework/Versions
using tar
(you could also use cp -a
etc.), installed version 4.1.0 again and
restored my backup.
Now I can use both versions.
User-based Library
But there was still something odd. Using version 4.0.5 I used to install new
R-packages in my user-directory beneath ~/Library/R/4.0/library
.
So I set up an anlogous directory ~/Library/R/4.1/library
and was surprised
that .libPaths()
doesn’t show me this directory.
So I took a look at the global config-file at /Library/Frameworks/R.framework/Versions/4.1/Resources/etc/Renviron
.
The environment variable R_LIBS_USER
was set to ${R_LIBS_USER-'~/Library/R/x86_64/4.1/library'}
.
So I removed the /x86_64
part and everythins was fine.
Transerfering Installed Packages
Next I wanted to transfer all my installed packages. So I exported a csv-file with all my installed packages using the old R-version running the following code
1 2 3 4 5 6 |
library(tidyverse) installed.packages() %>% as_tibble() %>% filter(!grepl("^/Library", LibPath)) %>% write_csv2(file = "packages.csv") |
So I got a list of my installed packages. Some of these packages were installed only from local repositories so I removed them manually off the list.
The resulting huge list of package names was installed with install.packages()
.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.