Tempting Shortcuts
Working notes on the slower path

Notes > Tech > here

installing and using R

R is a potent, open-source tool and environment for doing ?

Getting up and running

You can download the installer from the website or use Homebrew to install it.

  • normal install https://www.r-bloggers.com/installing-r-on-os-x/
  • homebrew https://www.r-bloggers.com/installing-r-on-os-x-100-homebrew-edition/
  • older http://stackoverflow.com/questions/20457290/installing-r-with-homebrew

The basic package is a command-line application, but the installer comes with a GUI. For an even more powerful environment one can install R-Studio.


I am interested in using computers to analyse text and so I thought that RQDA looked like a useful tool to do that with.

But installing it is terribly painful.

There are the R packages that can be installed directly, or you can use the github version

The issue seems to be RGtk2 not building against X11/XQuartz correctly.

1st approach: install older GTK w/X11

  • download and install a GTK build with X11 from http://r.research.att.com/
  • we now need to point various things to this framework, so in your .bashrc add

    export PKG_CONFIG_PATH=”/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig:/Library/Frameworks/GTK+.framework/Resources/lib/pkgconfig”


export LD_LIBRARY_PATH="/opt/X11/lib:/Library/Frameworks/GTK+.framework/Resources/lib"
  • trying to build things against this fails to locate a gdk file, we we need to edit one of the pkg-config files:

    sudo vi /Library/Frameworks/GTK+.framework/Resources/lib/pkgconfig/gdk-x11-2.0.pc add -I/opt/X11/include

  • build successful, we can then start building our R packages now.

    R CMD INSTALL RGtk2_2.20.31.tar.gz

  • and it builds successfully, but doesn’t load correctly, and so fails to install.

2nd approach: wrangling Homebrew

The gist of the issue seemed to be that Homebrew’s gtk was bulid with XQuartz in mind rather than X11 and that RGtk2 was built against Gtk with X11 and not Gtk with XQuartz.

It was this seemingly irrelevant post that put me on the path to solving this.

  • first, Homebrew’s cairo needs to be reinstalled with X11 support:

    brew uninstall –ignore-dependencies cairo brew install cairo –with-x11

  • then we need to change the configuration of Homebrew to build Gtk2 as we want:

    brew edit gtk under ‘def install’, change –with-gdktarget to =x11 append “–with-x” to the list

  • now build Gtk:

    brew install –build-from-source –verbose gtk

  • now for the R packages

    R CMD INSTALL RGtk2_2.20.31.tar.gz R CMD INSTALL cairoDevice_2.24.tar.gz

  • another failure, this time for igraph; but from https://github.com/hadley/xml2/issues/127 we can

    cp /usr/bin/xml2-config to ~/bin/ (or maybe /use/local/bin) edit this xml2-config to make line 3 prefix=/usr

  • more building…

    R CMD INSTALL igraph_1.0.1.tar.gz

Complete! And as a bonus, this process also enables rattle to install