Unable to load car package in R

Error Information:

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 ‘data.table’

Description of issue -
When I try to install the "car" package I get the error above.

Steps taken so far -
I tried to install using the following commands:

if (!require(car)) {
    install.packages("car")
    require(car)
}

AND

install.packages("car")
library("car")

I have also reinstalled R and RStudio but the issue seems to persists

System Information:

  • RStudio Edition: Desktop
  • RStudio Version: 1.1.456
  • OS Version: macOS High Sierra (10.13.6)
  • R Version: 3.5.1

Also:

  • RStudio diagnostics report:
[1] "1.1.456"

$R
[1] "/usr/local/bin/R"

$pdflatex
[1] ""

$bibtex
[1] ""

$gcc
[1] "/usr/bin/gcc"

$git
[1] "/usr/bin/git"

$svn
[1] "/usr/bin/svn"

R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS High Sierra 10.13.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets 
[6] methods   base     

other attached packages:
[1] carData_3.0-1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.18     rstudioapi_0.7   bindr_0.1.1     
 [4] magrittr_1.5     tidyselect_0.2.4 munsell_0.5.0   
 [7] colorspace_1.3-2 R6_2.2.2         rlang_0.2.2     
[10] plyr_1.8.4       dplyr_0.7.6      tools_3.5.1     
[13] grid_3.5.1       gtable_0.2.0     yaml_2.2.0      
[16] lazyeval_0.2.1   assertthat_0.2.0 tibble_1.4.2    
[19] crayon_1.3.4     bindrcpp_0.2.2   purrr_0.2.5     
[22] ggplot2_3.0.0    curl_3.2         glue_1.3.0      
[25] compiler_3.5.1   pillar_1.3.0     scales_1.0.0    
[28] pkgconfig_2.0.2 

SysInfo:
                                                                                          sysname 
                                                                                         "Darwin" 
                                                                                          release 
                                                                                         "17.7.0" 
                                                                                          version 
"Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64" 
                                                                                         nodename 
                                                                      "Martims-MacBook-Pro.local" 
                                                                                          machine 
                                                                                         "x86_64" 
                                                                                            login 
                                                                                         "martim" 
                                                                                             user 
                                                                                         "martim" 
                                                                                   effective_user 
                                                                                         "martim" 

R Version:
               _                           
platform       x86_64-apple-darwin15.6.0   
arch           x86_64                      
os             darwin15.6.0                
system         x86_64, darwin15.6.0        
status                                     
major          3                           
minor          5.1                         
year           2018                        
month          07                          
day            02                          
svn rev        74947                       
language       R                           
version.string R version 3.5.1 (2018-07-02)
nickname       Feather Spray               
$`__CF_USER_TEXT_ENCODING`
[1] "0x1F5:0x0:0x0"

$Apple_PubSub_Socket_Render
[1] "/private/tmp/com.apple.launchd.QeSQgRllFH/Render"

$CLICOLOR_FORCE
[1] "1"

$DISPLAY
[1] "/private/tmp/com.apple.launchd.o0JuU7flrO/org.macosforge.xquartz:0"

$DYLD_FALLBACK_LIBRARY_PATH
[1] "/Library/Frameworks/R.framework/Resources/lib:/Users/martim/lib:/usr/local/lib:/usr/lib:::/lib:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server"

$EDITOR
[1] "vi"

$GIT_ASKPASS
[1] "rpostback-askpass"

$HOME
[1] "/Users/martim"

$LANG
[1] "en_US.UTF-8"

$LC_CTYPE
[1] "en_US.UTF-8"

$LN_S
[1] "ln -s"

$LOGNAME
[1] "martim"

$MAKE
[1] "make"

$PAGER
[1] "/usr/bin/less"

$PATH
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin"

$R_BROWSER
[1] "/usr/bin/open"

$R_BZIPCMD
[1] "/usr/bin/bzip2"

$R_DOC_DIR
[1] "/Library/Frameworks/R.framework/Resources/doc"

$R_GZIPCMD
[1] "/usr/bin/gzip"

$R_HOME
[1] "/Library/Frameworks/R.framework/Resources"

$R_INCLUDE_DIR
[1] "/Library/Frameworks/R.framework/Resources/include"

$R_LIBS_SITE
[1] ""

$R_LIBS_USER
[1] "~/Library/R/3.5/library"

$R_PAPERSIZE
[1] "a4"

$R_PDFVIEWER
[1] "/usr/bin/open"

$R_PLATFORM
[1] "x86_64-apple-darwin15.6.0"

$R_PRINTCMD
[1] "lpr"

$R_QPDF
[1] "/Library/Frameworks/R.framework/Resources/bin/qpdf"

$R_RD4PDF
[1] "times,inconsolata,hyper"

$R_SESSION_TMPDIR
[1] "/var/folders/px/5b8zwjrs5c93xxl44zdkq5gc0000gn/T//RtmpNf4rMX"

$R_SHARE_DIR
[1] "/Library/Frameworks/R.framework/Resources/share"

$R_SYSTEM_ABI
[1] "osx,gcc,gxx,gfortran,?"

$R_TEXI2DVICMD
[1] "/usr/local/bin/texi2dvi"

$R_UNZIPCMD
[1] "/usr/bin/unzip"

$R_ZIPCMD
[1] "/usr/bin/zip"

$RMARKDOWN_MATHJAX_PATH
[1] "/Applications/RStudio.app/Contents/Resources/resources/mathjax-26"

$RS_RPOSTBACK_PATH
[1] "/Applications/RStudio.app/Contents/MacOS/rpostback"

$RS_SHARED_SECRET
[1] "ca6374de-b33b-4816-9b02-806b267cb853"

$RSTUDIO
[1] "1"

$RSTUDIO_CONSOLE_COLOR
[1] "256"

$RSTUDIO_CONSOLE_WIDTH
[1] "62"

$RSTUDIO_PANDOC
[1] "/Applications/RStudio.app/Contents/MacOS/pandoc"

$RSTUDIO_SESSION_PORT
[1] "41696"

$RSTUDIO_USER_IDENTITY
[1] "martim"

$RSTUDIO_WINUTILS
[1] "bin/winutils"

$SED
[1] "/usr/bin/sed"

$SHELL
[1] "/bin/bash"

$SSH_ASKPASS
[1] "rpostback-askpass"

$SSH_AUTH_SOCK
[1] "/private/tmp/com.apple.launchd.bcJzO8QeQm/Listeners"

$TAR
[1] "/usr/bin/tar"

$TERM
[1] "xterm-256color"

$TMPDIR
[1] "/var/folders/px/5b8zwjrs5c93xxl44zdkq5gc0000gn/T/"

$USER
[1] "martim"

$XPC_FLAGS
[1] "0x0"

$XPC_SERVICE_NAME
[1] "0"

 [1] ".GlobalEnv"        "package:carData"  
 [3] "tools:rstudio"     "package:stats"    
 [5] "package:graphics"  "package:grDevices"
 [7] "package:utils"     "package:datasets" 
 [9] "package:methods"   "Autoloads"        
[11] "package:base"     
Log file: rdesktop.log
--------------------------------------------------

(Empty)

Log file: rsession-martim.log
--------------------------------------------------

24 Sep 2018 03:06:13 [rsession-martim] CLIENT EXCEPTION (rsession-martim): (TypeError) : null is not an object (evaluating 'this.b.a');|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotPage.java#52::execute|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotWidget.java#49::onBrowserEvent|||com/google/gwt/user/client/DOM.java#1414::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#312::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#334::dispatchUnhandledEvent|||com/google/gwt/core/client/impl/Impl.java#244::apply|||com/google/gwt/core/client/impl/Impl.java#283::entry0|||http://127.0.0.1:44283/#-1::anonymous|||Client-ID: 33e600bb-c1b1-46bf-b562-ab5cba070b0e|||User-Agent: Mozilla/5.0 (Macintosh  Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)
24 Sep 2018 03:21:38 [rsession-martim] CLIENT EXCEPTION (rsession-martim): (TypeError) : null is not an object (evaluating 'this.b.a');|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotPage.java#52::execute|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotWidget.java#49::onBrowserEvent|||com/google/gwt/user/client/DOM.java#1414::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#312::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#334::dispatchUnhandledEvent|||com/google/gwt/core/client/impl/Impl.java#244::apply|||com/google/gwt/core/client/impl/Impl.java#283::entry0|||http://127.0.0.1:44283/#-1::anonymous|||Client-ID: 33e600bb-c1b1-46bf-b562-ab5cba070b0e|||User-Agent: Mozilla/5.0 (Macintosh  Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)
24 Sep 2018 15:57:48 [rsession-martim] CLIENT EXCEPTION (rsession-martim): (TypeError) : null is not an object (evaluating 'this.b.a');|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotPage.java#52::execute|||org/rstudio/studio/client/workbench/views/source/editors/text/ChunkPlotWidget.java#49::onBrowserEvent|||com/google/gwt/user/client/DOM.java#1414::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#312::dispatchEvent|||com/google/gwt/user/client/impl/DOMImplStandard.java#334::dispatchUnhandledEvent|||com/google/gwt/core/client/impl/Impl.java#244::apply|||com/google/gwt/core/client/impl/Impl.java#283::entry0|||http://127.0.0.1:44330/#-1::anonymous|||Client-ID: 33e600bb-c1b1-46bf-b562-ab5cba070b0e|||User-Agent: Mozilla/5.0 (Macintosh  Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko)

From Troubleshooting Guide: Using RStudio

1 Like

I think you have successfully installed car, but it is failing to load due to a missing dependency, the package data.table. Try install.packages("data.table"). If R wants to compile the package from source and runs into trouble, see this related discussion:

4 Likes

Thank you so much! Installing the binary version of data.table solved the issue

Great news! :grin: If your question's been answered (even by you!), would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

1 Like