Installing ggraph on Centos 7 when udunits2 is misbehaving

This is a bit specific and (hopefully) quite straight forward when you know how but I have spent the morning trying to figure it all out so perhaps this post will be helpful to someone.

The first step for me was to install udunits2 so head to your terminal and enter the following (you will need to enter your password when prompted):

sudo yum install udunits2-devel

All going well you can check that everything has installed in standard directories with a quick:

rpm -ql udunits2-devel

Hopefully your output will look something like this:

/usr/include/udunits2
/usr/include/udunits2/converter.h
/usr/include/udunits2/udunits.h
/usr/include/udunits2/udunits2.h
/usr/lib64/libudunits2.so

Next head back to your R or Rstudio console and enter:

install.packages('udunits2', type = 'source', repo = 'cran.rstudio.com', configure.args='--with-udunits2-include=/usr/include/udunits2')

Note the configure.args=’–with-udunits2-include=/usr/include/udunits2′ argument was the magic sauce for me as R couldn’t find my installation of udunits without it. Presumably you can modify this if your version of udunits2 is installed elsewhere.

And with that I was able to run:

 
install.packages('ggraph') 

which happily installed ggraph and all of its dependencies.

Hope that’s helpful if you have read this far!