问题
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).
回答1:
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.
回答2:
I had a similar problem with Ubuntu 16.04. Call terminal R and try to install one any package in the terminal. Then use rstudio.
回答3:
I had the same problem on Windows, maybe my solution works for you aswell. The default for R-Studio seems to be, that it looks for the packages in a folder that has the same name as the most recent R version you have installed.
So check in the Library Settings for R-Studio, (e. g. Tools -> Install packages -> Path beneath the search bar) it should say some path ending in ~/3.4.1 [Default]
, whereas the packages currently lie in ~/3.4
.
What I did:
Copy/move the content from ~/3.4
to ~/3.4.1
.
This is obviously not the nicest way, since that means moving the packages with every R update, but it worked for me.
Edit: formatting.
来源:https://stackoverflow.com/questions/44900631/rstudio-does-not-see-packages-after-update-to-r-3-4