I am am trying to load a simple dataset using:
library(car)
but I get the following error:
Error in library("car") : there is no package called 'car'
Does anyone have an idea why this happens and how to solve it?
If you don't currently use an IDE (or even if you do), the following will install the package:
install.packages("car")
Before then running
library("car")
You should heed @Iris's advice and use a RStudio if you don't already to manage just this sort of task.
You forgot to install the package before you tried to load it.
Do you use a IDE (integrated development environment)? I can strongly recommmand the use of Rstudio as IDE.
When you installed Rstudio, you can choose in the toolbar: "Tools" > "Install packages..."
Type in "car" and click "install".
As soon as the package is installed, you can load the package with library(car)
I know this post was from several months ago, but I came across it after having the same issue. I followed the instructions here (it's a .doc download).
I typically use R Studio, but was having no luck with this:
install.packages("car")
I opened the R application (not Studio) and followed the instructions on the .doc. I now have the package. Good luck!
For security purposes, I use R in a standard account on a Mac and download packages via a separate admin account. Yesterday I updated Microsoft R Open from 3.2.2 to 3.2.3 and I got this message when I tried to load Rcmdr:
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace ‘nlme’ 3.1-122 is being loaded, but >= 3.1.123 is required
Error: package ‘car’ could not be loaded
I had to log in to my admin account and check for updates. There was one for nlme, that I installed and that allowed car to load.
This worked for me. After downloading the most stable version of R (3.4.4), first, I install.packages("car",dependencies=TRUE) then install all the packages that when loading car I was asked for like haven, foreign, etc. So I installed them separately. Also, I noticed that when I install the packages they go to win-library folder instead of the actual working folder (the packages go to R\win-library\3.4 instead of R\R-3.4.4. So I copied them to the right folder.
I used Tools/Install packages... from R Studio and chose not to compile from source and do this for several packages it complains missing. And it works!
来源:https://stackoverflow.com/questions/27858474/car-package-not-found-by-r-failed-to-load