How to fix R package installation problems on Linux (libraries and their dependencies won't install)

preview_player
Показать описание

This tutorial shows you how to fix, once and for all, a very bad problem with running R (and Rstudio) on Linux. This problem is not well documented online, although I'm sure you've experienced this problem, too. This is where you try to install an R package, either through R directly or through Rstudio, and you get an error that one or more of the dependent packages were not installed. Therefore the installation fails. When you try to install the dependent packages, they also fail to install, because some of their dependencies were not installed, and so on. It makes no differences whether or not you use the "dependencies = TRUE" flag when performing the installation. You'll get the same problem.

The solution is provided in this video! I posted about it on an R help forum, and a couple of contributors helped me out. I share the solution here.

The overall steps are to uninstall all of the R libraries, uninstall R, uninstall Rstudio, reboot, and then reinstall R and Rstudio, and then install the r2u package, which provides the entire CRAN (R) repository as local binaries. From then on, R will install your packages from the local binaries with no problems.

All the code you'll need is found here:

Here is a link for installing R and Rstudio under Ubuntu Linux:
Рекомендации по теме
Комментарии
Автор

I got the following error. regarding reinstalling all paclages. I am running this code in Rstudio as bspm doesnt work in terminal. I am using Ubuntu 24.
> setwd ('/home/tanzeela/Downloads')
> bspm::enable()
Tracing function "install.packages" in package "utils"
> to_reinstall <- read.csv
> install.packages(to_reinstall[, 1], dependencies = TRUE, ask = FALSE)
Error: dbus: Call failed: Launch helper exited with unknown return code 1

TanzeelaArshad-ne
Автор

thank you, thank you, thank you
i lost my job and thus my mac and I"ve been subsisting on a revamped 2012 mac onto which I installed Ubuntu. But I could not for months get R to work.
Until now

desryan
Автор

I have Ubuntu 22.04 and these instructions never work when i run the commands as a super user (sudo). It is essential to unlock the root account in the terminal then run these commands as a root user. Thanks for sharing such valuable information and experiences.

mmk
Автор

Thank you so much for this! I was having the same problems, going in circles and your walk through was really helpful for someone who is trying to learn how all this works. I am running into issues using Swirl to learn R. I requires me to install "R Programming" and can't find anything recent that is helpful. Have you got any tips on how to go about this? I have tried manually installing and also trying to let Swirl install it, but I get "Could not connect to course file" and "Cannot create dir" or No such file or directory
I am running Ubuntu v.22.04 if that helps.

neonwhale
Автор

At the step "bspm::enable()" it said there is no package called "bspm".
I followed all the steps correctly from the beginning of the video.
I am using Ubuntu 24

TanzeelaArshad-ne
Автор

Which program is it? Why my linux terminal is all black with no option

BeBa_