0

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. (i.e.(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
user2554330
  • 37,248
  • 4
  • 43
  • 90
  • what version of R are you running? also `install.packages("openxlsx")` might help as it says you don't have that either – morgan121 Nov 27 '18 at 23:25

1 Answers1

0

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.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • Thank you. This was helpful. For the short term fix i had to go through the process with two more errors but it finally worked. Can you be more specific as to how i add my .libPaths("my first line") to my R.profile? – Wkinsley Dec 04 '18 at 01:07
  • Just edit the file and put that line into it. It might not exist yet, in which case you need to create it. You're on Windows and I'm not, and I forget where `.Rprofile` is located on Windows, but the `?Startup` help topic should say. – user2554330 Dec 04 '18 at 11:05