Install dependencies - R

package-dependencies

#1

I'm trying to install a few packages, but getting errors because dependencies are not installed for some of them.

I'm doing:

x <- c("ggmap", "rgdal", "rgeos", "maptools", "dplyr", "tidyr", "tmap")
# install.packages(x) # warning: uncommenting this may take a number of minutes
lapply(x, install.packages) # install packages

But I'm getting:

* DONE (leaflet)
ERROR: dependencies ‘geojsonio’, ‘geojsonlint’, ‘sf’, ‘V8’ are not available for package ‘rmapshaper’
* removing ‘/home/ogonzales/R/x86_64-pc-linux-gnu-library/3.4/rmapshaper’
Warning in install.packages :
  installation of package ‘rmapshaper’ had non-zero exit status
ERROR: dependencies ‘gdalUtils’, ‘sf’, ‘svglite’ are not available for package ‘mapview’
* removing ‘/home/ogonzales/R/x86_64-pc-linux-gnu-library/3.4/mapview’

Is there a way to capture this "not present" dependencies in order to install them and then restart the installation of the first packages?

I would prefer not to install these dependencies 1 by 1, and then proceed with the packages I'm really interested in.

Thank you.


#2

The standard procedure when this happens is to narrow down to the package that is causing the problem. So when debugging don't try to install all packages at once, go through them one by one. Then when you find the problem package, see if you can install its dependencies. Finally, you will come to the problem package. After that it's usually a simple google and you're sorted.

In this case, I'm guessing it's the spatial packages. So you probably need to run

# For linux
sudo aptitude install libgdal-dev

To answer your other question,

Is there a way to capture this "not present" dependencies in order to install them and then restart the installation of the first packages?

No (or not easily). It would only be really worth it if bandwidth was really precious, otherwise, just reinstall. Basically, you need an additional (non R) library installed that is OS dependent.


#3

I was trying to automate the installation of the dependencies that are required. I'm using Ubuntu, if there is not way of doing this, I'll have to narrow the installation package by package and make sure to install any dependecy that is not present.

Thank you.