Why do I get Error when calling library (rdd) - r

I have installed the rdd package, when calling library(rdd), I get error an message:
Error: package ‘car’ required by ‘AER’ could not be found"
I have used functions from car (like anova) so I know I have it.
I have MAC OS 10.15.1, R 3.6.1 , I reinstalled R and RStudio.
install.packages("rdd")
library(rdd)
Loading required package: AER
Error: package ‘car’ required by ‘AER’ could not be found

Packages may have dependencies (i.e. other packages) and those dependent package may have dependencies of their very own. Appears that rdd requires AER which in turn requires car. So you need all three (and possibly even more). At the very least you need to now install pkg:car.
(I know this may seem a duplicate but I'm not sure the usual duplicate nominees have seen a multi-level dependency situation such as this. )
Suggest you execute both of this lines:
install.packages("AER", dependencies=TRUE) # should pick up car
# maybe also need install.packages("car", dependencies=TRUE)
install.packages("rdd", dependencies=TRUE)
If you get further errors, pay attention to the first error message and use install package recursively until you establish a full set of dependencies and dependencies of dependencies.

Related

Issue with loading Tidyverse in RStudio

How to do i resolve the following code error?
library(tidyverse)
Error: package or namespace load failed for ‘tidyverse’:
.onLoad failed in loadNamespace() for 'tidyselect', details:
call: is_string(x)
error: object 'rlang_is_string' not found
In addition: Warning message:
package ‘tidyverse’ was built under R version 3.5.3
For persistent errors of type, first, ensure you are working with the latest version of R. The installr package is a very convenient way to do this.
Then, start new R session (ideally, not in RStudio).
Uninstall tidyverse, tidyselect, and rlang
# if you are using multiple libraries, you may need to specify libpath,
# using the following: lib="~/R/win-library/3.6"
# you can check using the .libPaths() command
remove.packages("rlang")
remove.packages("tidyselect")
remove.packages("tidyverse")
and, reinstall them one by one with dependencies = TRUE
install.packages("rlang", dependencies = TRUE)
install.packages("tidyselect", dependencies = TRUE)
install.packages("tidyverse", dependencies = TRUE)
That should do it.
I also encounter a similar problem like you, which I'm unable to load the tidyverse too.
Hope this discuss from the tidyverse github issues maybe relevant to you.
https://github.com/tidyverse/googledrive/issues/275
Here's one of our typical explanations of this. Note that this is not specific to googledrive or rlang. It's an R + Windows gotcha. I suspect for you is rlang (at least).
Please note that on Windows, it is very important to quit or restart
all R processes before upgrading , because if any R process has
loaded, it will keep the .dll file open and the installer will not be
able to overwrite .dll. The error message when this happens is very
easy to overlook, and the new version will be partially installed: the
package description and R code will be updated but the compiled code
(in .dll) will not.

R packages not loading via library()

I have been experiencing the problem of not being able to load package libraries in R. The packages install fine via instal.packages(), but I get the error
Error: package or namespace load failed for ‘adegenet’ in library.dynam(lib, package, package.lib):
shared object ‘httpuv.so’ not found
Error: package ‘adegenet’ could not be loaded
When I attempt to load the package 'adegenet' (and any other packages).
I recall this behaviour started to occur when I used remove.packages() to remove shiny in order to install the development version on GitHub (shiny-Incubator).
I am unsure as to what is going on. Any ideas on how to restore everything? I updated to the most recent R version, but this did not fix things.
It seems that during your uninstallation procedure you managed to remove a component of httpuv and/or Rcpp. This should get things working again:
install.packages(c("Rcpp", "httpuv"))

Addressing the "cannot remove prior installation of package" error when updating multiple packages at once

This is a problem that comes up repeatedly, e.g.
Error in install.packages : cannot remove prior installation of package ‘DBI’
Warning in install.packages : cannot remove prior installation of package ‘data.table’
Unable to install package forecast in R
Install error of package plyr
Unable to install package zoo
I have come across this issue multiple times. Most annoying is when it occurs with a bunch of packages; e.g. I do something like
update.packages(ask = FALSE)
and get a number of these errors. The error is misleading though, because R tends to actually remove the old package version---but then doesn't install the new version. Once this happens, you can't fix it with update.packages; you have to reinstall it from scratch.
The most frustrating aspect of this problem is that it often occurs when installing dependencies, so e.g. I might successfully update dplyr, but in the process Rcpp is removed. Now I can't load dplyr because Rcpp is missing, so I need to reinstall Rcpp.
My current workaround (when the number of uninstalled packages is large) is to close all of my R sessions, open a new one with the base R GUI (i.e. not RStudio or RTVS) and do
lapply(dir(.libPaths()), install.packages)
which reinstalls my entire library. This is overkill.
Is there a better way to check which folders in .libPaths() actually contain packages, so that I only reinstall the missing packages?
Alternatively: Is there a better way to check for missing package depedencies?
One strategy is to do
setdiff(dir(.libPaths()), .packages(all = TRUE))
To get a list of directories in the library that don't seem to actually contain packages. Now I have a much smaller list of packages to reinstall.
I'm not sure if it's foolproof, but it's better than reinstalling my entire library.

cannot load rms package

I'm working with R, I have installed the library 'rms' but I have the follow error:
> library(rms)
Error in library.dynam(lib, package, package.lib) :
DLL ‘colorspace’ not found: maybe not installed for this architecture?
Errore: package ‘ggplot2’ could not be loaded
What can I do?
If you install from base R and wish to install a package and all its dependencies, you need to use the argument dependencies = TRUE. From ?install.packages:
"dependencies = TRUE ... this installs all the packages needed to run pkgs, their examples, tests and vignettes (if the package author specified them correctly).
Hence,
install.packages("rms",dependencies = TRUE)
should do the trick.
The answer offered so far (without any upvotes so far) is useful, but incomplete. It is sometimes sufficient to execute install.packages() with dependencies = TRUE, but if the missing package is a dependency of a dependency, then install.package is not "smart" enough to recognize that fact. The ggplot2 package is in the "Depends:" line of the rms package DESCRIPTION file, but colorspace is not. Sometimes the end-user simply needs to read the error message and install the missing dependencies.
In this case, however, it appears that there may have been a version mismatch of packages and R.

How force R to load package, `library()` fails due to dependency?

How force R to load package when some (not crucial) packages it depends on aren't installed ?
Motivation : sometimes I have to use R in places, where I can't automatically install required packages. Doing so manually is very time consuming and in most cases I need only a vary small part of functions contained in installed package.
Typical message error in this case is :
> library(packageX)
Loading required package: packageY
Error: package ‘packageY’ could not be loaded
In addition: Warning messages:
In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called ‘packageY’
Mayby 'devtools' package will be helpful. But I haven't investigate it.
If you cannot install the dependencies, I think your only option is to remove those packages from the Depends field of DESCRIPTION file of packageX and try to rebuild packageX
You can look at the source of the package to figure out which functions you need and what dependencies they need. You may want to collaborate with the author/maintainer of the package on this part. You could create a private version of the package that does not have the dependencies and the other functionality that you don't need.
If this is only for your personal use and the license for the package allows it (gpl and similar) then you don't need the authors permission to extract those pieces you want. If you want to link your package to this for distribution then you should work with the original author. I know a couple of package authors wanted just a couple of functions from one of my packages and I agreed that loading my entire package (and dependencies) was overkill for what they wanted to do, so I worked with them and they have copies of the functions in their package without needing to depend on mine. When I update one of the functions I send a copy to them to update their copy as well.

Resources