Installing Rattle on macOS

Installing Rattle on MacOS 10.11 (or above)

Guys, great news! Follow Yihui’s comment below and use the 20-line code to install Rattle without any effort! Just copy and paste the codes in R/RStudio - it just works like a charm!

Note that you need to install Homebrew first (step 3 below). Next you can run Yihui’s code, which is copied below:

system('brew install gtk+')

  if ([['sysname']] != 'Darwin') return()

  .Platform$pkgType = 'mac.binary.el-capitan'
  unlockBinding('.Platform', baseenv())
  assign('.Platform', .Platform, 'package:base')
  lockBinding('.Platform', baseenv())

    pkgType = 'both', install.packages.compile.from.source = 'always',
    repos = ''

install.packages(c('RGtk2', 'cairoDevice', 'rattle'))

This document describes steps to successfully install Rattle R Analytic Tool To Learn Easily on macOS 10.11 or above. If you have a macOS lower than 10.11, I recommend you upgrade your system to the newest one (10.12 macOS Sierra using App Store. Without macOS 10.11 or above, you cannot install R 3.4, let alone RGtk2, which now only supports the newest R version.

Throughout the steps to get your Rattle working, we will be using Terminal. You can open it by using Spotlight Search (you can open it by command+space, which is the default shortcut). Type terminal and you will be able to find it and open it.

Note that starting from step 7, I mainly followed instructions on @williamtellme123’s comment (the second to last)

  1. Enter the following command in terminal to check your macOS version. Expected output is as below the dashed line ---.
    ~$ sw_vers
    ProductName:	Mac OS X
    ProductVersion:	10.12.6
    BuildVersion:	16G29
  2. If your system is above 10.11, continue. Otherwise, upgrade it to Sierra.

  3. Install homebrew, which is a very convenient package manager for macOS. Copy the following command in terminal and hit Enter:
    ~$ /usr/bin/ruby -e "$(curl -fsSL"

    Follow the instructions to get brew ready. When inputing your password, nothing will show up for security reasons. Just hit Enter when you’re finished.

  4. When brew is finished, copy the following command in terminal and hit Enter:
    ~$ touch ~/.bash_profile
    ~$ echo "export PATH=/usr/local/bin:$PATH
    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig" >> ~/.bash_profile
    ~$ source ~/.bash_profile
  5. Next, check your R version:
    ~$ R --version
    R version 3.4.1 (2017-06-30) -- "Single Candle"
    Copyright (C) 2017 The R Foundation for Statistical Computing
    Platform: x86_64-apple-darwin16.6.0 (64-bit)
  6. If yours is 3.4, continue. Otherwise, upgrade it.

  7. Enter the following into your terminal:
    ~$ brew uninstall --force cairo --ignore-dependencies
    ~$ brew cask install xquartz
    ~$ brew install --with-x11 cairo
  8. Next, we need to tell brew to change the way it wants to install gtk+. A text editor window will pop up. Note that if you are not familiar with vim, run export EDITOR=emacs in terminal before the line above to force using emacs, where you can use it as other common text editors.
    ~$ brew edit gtk+

    Find where there is something like this:

    def install
     args = [
             # "--disable-visibility",
             # "--with-gdktarget=quartz",

    The original version that you just opened will be exactly the same, except the bottom two lines. Replace the whole chunk by this one. Then hit ctrl+x ctrl+c, followed by y to quit emacs.

  9. Now we can install gtk+ by:
    ~$ brew install --build-from-source --verbose gtk+

    After installation succeeds, run this in terminal: echo "export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib/pkgconfig/gtk+-2.0.pc:/opt/X11/lib/pkgconfig" >> ~/.bash_profile. Otherwise, gtk+ will not be recognized.

  10. Download the newest source file for RGtk2 from

  11. Assume that the path to this file is ~/Downloads. Run the following in terminal:
    ~$ cd ~/Downloads
    ~/Downloads$ R CMD INSTALL RGtk2_2.20.33.tar.gz

    Note that versions may vary depending on when you download the source file. Use the exact filename that sits in the directory. (Tip: use tab to help autocomplete.)

  12. When it finishes, open XQuartz by using spotlight search.

  13. A window that’s very similar to terminal will pop up. Type r and hit enter to open R.

  14. In R, run:
    >> install.packages("", repos=NULL, type="source")
  15. Then try rattle library:
    >> library(rattle)
    >> rattle()
  16. Rattle will show up and it may ask you whether to install XML and cairoDevice. Click yes for both and you should be good to go now.
Zhiya Zuo

Zhiya Zuo

Filet-O-Fish 🍔 is the BEST!

comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora