How to install the R package topicmodels on OS X

Many people have reported problems when attempting to install the R package `topicmodels` on R when using OS X Mavericks or Yosemite. The problem is that the binaries are not yet built for these versions of OS X, and you need additional software installed in order to build the source. Once you have built the package from source, however, it seems to work fine.

Here is the solution that worked for me:

  1. Install the free  XCode from the App Store. After installation, you need to open the application XCode from the Applications folder, so that it can install the needed components.

  2. You need the gsl ( Gnu Scientific Library) installed. One way is to get the latest version from  [](" rel=“nofollow). A better solution (in my opinion) is to install using  homebrew. From Terminal, type:

     ruby -e "$(curl -fsSL"

Then install gsl using:

    brew install gsl
  1. Now, from R, try

     install.packages("modeltools")   # a dependency of topicmodels
     install.packages("topicmodels", type="source")  # should compile from source

If for some reason the second command fails, then try

    install.packages("", repos=NULL, type="source")
Ken Benoit
Ken Benoit
Professor of Computational Social Science
comments powered by Disqus