Install R Package "sf"

thethirtyfour
New Contributor III

Hi,

I am trying to install the following four dependency packages in order to install "slu-openGIS/postmastr" directly from GitHub:

  • units
  • sf
  • tigris
  • tidycensus

When attempting to install "units", I received the following configuration error:

 

%r
install.packages("units")

  Configuration failed because libudunits2.so was not found. Try installing:
    * deb: libudunits2-dev (Debian, Ubuntu, ...)
    * rpm: udunits2-devel (Fedora, EPEL, ...)
    * brew: udunits (OSX)

 

I was able to install this package as follows, based on @Retired_mod  response:

 

%r
system("sudo apt-get install libudunits2-dev -y")
install.packages("units")

 

 However, I receive the below error when attempting to install the "sf" package. Can someone please assist? 

Thank you!

 

%r
install.packages("sf")

* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc
configure: CXX: g++ -std=gnu++17
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/local_disk0/.ephemeral_nfs/envs/rEnv-2f880f79-1361-4a3a-92e5-62a9d12ddcce/sf’
Installing package into ‘/local_disk0/.ephemeral_nfs/envs/rEnv-2f880f79-1361-4a3a-92e5-62a9d12ddcce’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/sf_1.0-15.tar.gz'
Content type 'application/x-gzip' length 3485450 bytes (3.3 MB)
==================================================
downloaded 3.3 MB

Warning in utils::install.packages(pkgs, ...) :
  installation of package ‘sf’ had non-zero exit status