简体   繁体   中英

“Rcmdr” error load failed for ‘car’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):

I'm attempting to run 'Rcmdr' in R. I had it fully functional and accidentally exited the program. Now i can not get back in.
I've tried a number of things; uninstall and reinstalling R uninstall and reinstalling 'Rcmdr' I tried manually installing Trying different 'CRAN's and all of the suggestions i saw from previous posts. (ie(install.packages("car",dependencies=TRUE)
Below is the error I'm receiving.

The downloaded binary packages are in C:\\Users\\william\\AppData\\Local\\Temp\\Rtmpuazyss\\downloaded_packages

> library(Rcmdr)
Loading required package: RcmdrMisc
Loading required package: car
Error: package or namespace load failed for ‘car’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
 there is no package called ‘openxlsx’
Error: package ‘car’ could not be loaded

A common cause of errors like this is that you are working on a system where you don't have write permission on the R package library. You install a package (likely openxlsx in this case), and since it can't write to the system library, it creates a private library for you somewhere where you do have write permission.

But then when you start a new session, it doesn't look in that location, so it thinks openxlsx is not installed, and you get an error like the one you saw.

A short term fix is to just re-install the missing package. But then you'll get the same error in the next session if you restart R.

A better fix is to tell R to look in your private library. You can find where it is after re-installing openxlsx by running

.libPaths()

The first entry in the result will probably be your private library, the second entry will be the standard system one. (You could have more than 2, but that's not likely unless you've already asked for more.) To make sure that your private library always shows up, you need to put the line

.libPaths("whatever was in the first entry")

into a file called .Rprofile in your home directory. For example, I see

> .libPaths()
[1] "/Users/me/R/contrib"                             
[2] "/Library/Frameworks/R.framework/Versions/3.5/Resources/library"

so I should have

.libPaths("/Users/me/R/contrib")

in my .Rprofile . You'll see some other directory there, use it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM