Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RStudio does not see packages after update to R 3.4 [duplicate]

Tags:

path

r

I have Ubuntu 16.04 and after update of R to 3.4.1 version it does not see my packages even though they have also been updated:

> library(dplyr)
Error in library(dplyr) : there is no package called ‘dplyr’

Packages are there:

$ ls ~/R/x86_64-pc-linux-gnu-library/3.4/ | grep plyr
dplyr
plyr

My .libPaths:

> .libPaths()
[1] "/usr/local/lib/R/site-library" "/usr/lib/R/site-library"       "/usr/lib/R/library" 

Setting .libPaths to desired path does the thing just for one session. I'd like it to be permanent.

I also tried to set the variables R_LIBS, R_LIBS_SITE and R_LIBS_USER to desired path as indicated here but it worked only in the console (didn't work in RStudio).

like image 588
potockan Avatar asked Jul 04 '17 08:07

potockan


People also ask

Do you need to reinstall packages after updating R?

Once the package is installed, you keep that in your R library associated with your current major version of R. You will need to update & reinstall packages each time you update a major version of R.

Why is my RStudio not installing packages?

Make sure that the package is available through CRAN or another repository, that you're spelling the name of the package correctly, and that it's available for the version of R you are running.

What do I do when R package is not available?

Sometimes the package maintainer may show R version gaps that it does not support. In that case, you have at least two options: 1) upgrade your R version to the next one the target package already supports, 2) install the most recent version from the older ones available that would work with your R version.


1 Answers

Found the solution: In the file /usr/lib/R/etc/Renviron there is a configuration of R.

In lines 43-45 there is:

# edd Jun 2017  Comment-out R_LIBS_USER
#R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}
##R_LIBS_USER=${R_LIBS_USER-'~/Library/R/3.4/library'}

I have uncommented R_LIBS_USER=${R_LIBS_USER-'~/R/x86_64-pc-linux-gnu-library/3.4'}, restarted RStudio and now it works.

EDIT: Looking at the comments, it seems like a planned behaviour. Here is another solution.

like image 69
potockan Avatar answered Sep 19 '22 06:09

potockan