[r] Error in installation a R package

Please help me, I cannot install "MASS" package.

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

I tried to install MASS package from local:

> utils:::menuInstallLocal()  
package ‘MASS’ successfully unpacked and MD5 sums checked  
Warning: cannot remove prior installation of package ‘MASS’

Even I cannot remove "MASS":

> remove.packages("MASS")  
Removing package from ‘C:/Program Files/R/R-3.0.1/library’  
(as ‘lib’ is unspecified)  
Error in find.package(pkgs, lib) : there is no package called ‘MASS’

Also with this option I couldn't install package:

> options(install.lock=T)  
> utils:::menuInstallLocal()  
package ‘MASS’ successfully unpacked and MD5 sums checked  
Warning: cannot remove prior installation of package ‘MASS’  
Warning: restored ‘MASS’  
Warning message:  
In file.copy(savedcopy, lib, recursive = TRUE) :  
  problem copying C:\Program Files\R\R-3.0.1\library\00LOCK\MASS\libs\x64\MASS.dll to C:\Program Files\R\R-3.0.1\library\MASS\libs\x64\MASS.dll: Permission 

And with install.packages:

> install.packages("C:\\MASS_7.3-35.zip",repos=NULL)
package ‘MASS’ successfully unpacked and MD5 sums checked  
Warning: cannot remove prior installation of package ‘MASS’  
Warning: restored ‘MASS’  
Warning message:  
In file.copy(savedcopy, lib, recursive = TRUE) :  
  problem copying C:\Program Files\R\R-3.0.1\library\00LOCK\MASS\libs\x64\MASS.dll to C:\Program Files\R\R-3.0.1\library\MASS\libs\x64\MASS.dll: Permission 

I should mention I use R with ORE (Oracle R Enterprise).

This question is related to r installation package

The answer is


In my case, I had to close R session and reinstall all packages. In that session I worked with large tables, I suspect this might have had the effect.


In my case, the installation of nlme package is in trouble:

mv: cannot move '/home/guanshim/R/x86_64-pc-linux-gnu-library/3.4/nlme' 
to '/home/guanshim/R/x86_64-pc-linux-gnu-library/3.4/00LOCK-nlme/nlme': 
Permission denied

Using Ubuntu 18.04, CTRL+ALT+T to open a terminal window:

sudo R
install.packages('nlme')
q()

The solution indicated by Guannan Shen has one drawback that usually goes unnoticed.

When you run sudo R in order to run install.packages() as superuser, the directories in which you install the library end up belonging to root user, a.k.a., the superuser.

So, next time you need to update your libraries, you will not remember that you ran sudo, therefore leaving root as the owner of the files and directories; that eventually causes the error when trying to move files, because no one can overwrite root but themself.

That can be averted by running

sudo chown -R yourusername:yourusername *

in the directory lib that contains your local libraries, replacing yourusername by the adequated value in your installation. Then you try installing once again.


I had the same problem with e1071 package. Just close any other R sessions running parallelly and you will be good to go.


After using the wrong quotation mark characters in install.packages(), correcting the quote marks yielded the "cannot remove prior installation" error. Closing and restarting R worked.


Examples related to r

How to get AIC from Conway–Maxwell-Poisson regression via COM-poisson package in R? R : how to simply repeat a command? session not created: This version of ChromeDriver only supports Chrome version 74 error with ChromeDriver Chrome using Selenium How to show code but hide output in RMarkdown? remove kernel on jupyter notebook Function to calculate R2 (R-squared) in R Center Plot title in ggplot2 R ggplot2: stat_count() must not be used with a y aesthetic error in Bar graph R multiple conditions in if statement What does "The following object is masked from 'package:xxx'" mean?

Examples related to installation

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user) Conda version pip install -r requirements.txt --target ./lib How to avoid the "Windows Defender SmartScreen prevented an unrecognized app from starting warning" PackagesNotFoundError: The following packages are not available from current channels: Tensorflow import error: No module named 'tensorflow' Downgrade npm to an older version Create Setup/MSI installer in Visual Studio 2017 how to install tensorflow on anaconda python 3.6 Application Installation Failed in Android Studio How to install pip for Python 3.6 on Ubuntu 16.10?

Examples related to package

ModuleNotFoundError: No module named 'sklearn' Python: How to pip install opencv2 with specific version 2.4.9? Relative imports - ModuleNotFoundError: No module named x Is __init__.py not required for packages in Python 3.3+ "pip install unroll": "python setup.py egg_info" failed with error code 1 Unable to Install Any Package in Visual Studio 2015 beyond top level package error in relative import How can I specify the required Node.js version in package.json? "installation of package 'FILE_PATH' had non-zero exit status" in R Error in installation a R package