5

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?

Rich Scriven
  • 97,041
  • 11
  • 181
  • 245
fabiof
  • 89
  • 1
  • 1
  • 6

6 Answers6

9

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.

Phil
  • 4,344
  • 2
  • 23
  • 33
  • 2
    I still cannot install car library after running `install.packages("car")`, there is always a error: `Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : namespace ‘pbkrtest’ 0.4-2 is being loaded, but >= 0.4.4 is required In addition: Warning message: package ‘car’ was built under R version 3.2.3 Error: package or namespace load failed for ‘car’` – JW.ZG Feb 16 '16 at 22:01
  • @JW.ZG You should open this as another question. If/when you do, add the results of `sessionInfo()` and this will help others diagnose your problem. – Phil Feb 17 '16 at 10:34
2

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)

Iris
  • 1,072
  • 3
  • 10
  • 22
1

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!

Bruce P
  • 19,995
  • 8
  • 63
  • 73
travissari
  • 11
  • 1
1

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.

FTF
  • 181
  • 3
  • 11
1

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.

Heerbod
  • 53
  • 9
1

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!

Harry
  • 1,147
  • 13
  • 13