Car package not found by R (failed to load) - r

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!

Related

R packages "raster" fail to upload while searching for "terra" last version

I'm working in Windows 10 with R 4.1.2 in RStudio 2021.09.2. I'm working with spatial data, both vectors and rasters, but three days ago the command library(raster) started to gave me this warning:
Error: package or namespace load failed for ‘raster’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
namespace ‘terra’ 1.4-22 loaded, but >= 1.5.12 is required
I tried to update terra, the update finished successfully but the
version remains 1.4-22.
I tried also to remove the packages (terra, raster, sf), then install
again everything, but the error remains.
Finally, I tried the following:
require(devtools)
install_version("terra", version = "1.5-12", repos = "https://cran.r-project.org/src/contrib/Archive/terra/terra_1.5-12.tar.gz")
but in the end the version is the same, 1.4-22. I tried again:
packageurl <- "https://cran.r-project.org/src/contrib/Archive/terra/terra_1.5-12.tar.gz"
install.packages(packageurl, repos=NULL, type="source")
And nothing changed, unfortunately.
Is anyone experimenting something similar? How could I fix this error, in your opinion?
There are a lot of packages based on terra and I got stuck because seems that none of them can work without this update.
Thank you for your help!
Thank you to all the kind persons who tried to answer.
I finally fixed the problem by:
restarting R in a clean new session
removing terra package
quitting R, then restarting again
installing the package terra asking for the development version:
install.packages('terra', repos='https://rspatial.r-universe.dev')
I had the same issue. I was able to solve doing the following steps:
Download and install RTools: https://cran.r-project.org/bin/windows/Rtools/rtools40.html
Open RStudio and run install.packages("terra").
Confirm that you want to install it from source.
Wait while console compile the terra package.
Done! You can now load the raster package.
Have you tried to update terra directly through R Studio interface, on the "Packages" tab? I was facing the same issue but managed to fix it by doing so.

r package installed properly but "there is no package called ‘DiabetesTxPath-master" error

I'm trying to install a package called "DiabetesTxPath-master" from local files.(The file can be downloaded in https://github.com/rohit43/DiabetesTxPath)
I used the code below installing it.
'filename<-"DiabetesTxPath-master.zip"'
install.packages(filename,type="binary",repos=NULL)
but when I try to load the packaged by the code below,
library(DiabetesTxPath)
error comes up.
there is no package called ‘DiabetesTxPath-master'
There is no problem in location.
.libPaths()
[1] "C:/Program Files/R/R-3.4.2/library"'
and this is where I want my package to be installed.
(and I see my packaged installed in the folder with my eyes!)
2.I've also tried to run as an administrator. it didn't work either.
So what could be the probelm, and how could I fix this?
Any comment would be appreciated so much.
I've been trying it so hard for a week.
Try using
library(devtools)
install_github("rohit43/DiabetesTxPath")
the problem arises because the dependencies for this package
ERROR: dependencies 'FeatureExtraction', 'CohortMethod',
'OhdsiSharing' are not available for package 'DiabetesTxPath'
are not available for this package in R 3.5 and above .
Now you need to install older version of R where these dependencies were supported and try using the above method.

Manual install of R-package "xlsReadWrite" on OS X

I'm having trouble with manual install of an R-package called "xlsReadWrite." I know there are other packages available that can read Excel or csv files in to R, but I need to use this specific package as it is integrated in various places of a quite long script I want to use.
I'm using R-Studio Version 0.98.1091 on a Mac OS X (10.10.3)
The package is no longer available on CRAN, but there's a zip file available online here:
http://www.swissr.org/download
I can manually install the package but then when I hit the check mark I get the following error output:
library("xlsReadWrite", lib.loc="/Library/Frameworks/R.framework/Versions/3.1/Resources/library")
Error in library.dynam(lib, package, package.lib) :
shared object ‘xlsReadWrite.so’ not found
Error: package or namespace load failed for ‘xlsReadWrite’
I don't know quite how to interpret this. Does anyone have a way of successfully installing this package? Thanks a million in advance!!!
Ben

How to install the e1071 package in R 2.15.0

I want to use the skewness() and kurtosis() functions from the e1071 package. I have tried downloading the e1071 package with
install.packages("e1071", dep = TRUE)
but it still doesn't seem to work. So I am wondering if it is the wrong version I installed. I've tried searching the CRAN site but I can't seem to find the version for R 2.15.0.
So I was wondering if I was doing it wrong or could someone please give me the link to the e1071 package, version 2.15.0.
You could try this:
go to the
https://cran.r-project.org/web/packages/e1071/index.html
get the windows Finding the windows binary filebinaries for the library and put it in your library folder within the R installation. Then load the library within R
library(e1071)
:)
Well I did like this
if you are using Rstudio
go to packages in the right windows
click on install
write e1071
click install and it will work
In R (for OSX) select Packages & Data -> Package Installer from the menu. If you haven't already select a Datacenter.
Then you can search for the package and install it via Install selected
Then you can use the package via:
> library(e1071)
This is how I did it for mac:
1) Download the binary - https://CRAN.R-project.org/package=e1071
2) Run R CMD INSTALL e1071_version.tgz
After this i tried to load the library but ran into the following problem. If you don't you can skip the step below.
Error: package or namespace load failed for ‘e1071’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/ME/anaconda3/lib/R/library/e1071/libs/e1071.so':
dlopen(/Users/ME/anaconda3/lib/R/library/e1071/libs/e1071.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
Referenced from: /Users/ME/anaconda3/lib/R/library/e1071/libs/e1071.so
Reason: image not found
3) Copy /Users/ME/anaconda3/lib/R/lib/libR.dylib /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libR.dylib
A soft link might work as well but i just copied the whole lib.

Error while installing R package: package built for universal-apple-darwin

I installed a R package as suggested by How do I install an R package from source?, using R CMD INSTALL [my_pkg_path.tgz]. Package sources are downloaded from r-project.org, e.g., http://cran.r-project.org/web/packages/fields/index.html
However, when I try to load the package using say library(fields), I got the error that complains the package are built for universal-apple-darwin:
Error: package ‘fields’ was built for universal-apple-darwin9.8.0
Guess it's something to do with architecture, but no idea how to resolve it. Any idea? Thanks.
It looks like you downloaded the package's Mac OSX binary file, which usually ends in .tgz - try downloading the package source (usually something ending in .tar.gz) and installing the package again.
Depending on what your operating system is, you may need an additional set of software before you can install packages from source. If the above suggestion doesn't work, would you provide some information about the OS, for example from sessionInfo()?

Resources