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+')
local({
if (Sys.info()[['sysname']] != 'Darwin') return()
.Platform$pkgType = 'mac.binary.el-capitan'
unlockBinding('.Platform', baseenv())
assign('.Platform', .Platform, 'package:base')
lockBinding('.Platform', baseenv())
options(
pkgType = 'both', install.packages.compile.from.source = 'always',
repos = 'https://macos.rbind.org'
)
})
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)
- 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 -
If your system is above 10.11, continue. Otherwise, upgrade it to
Sierra. - Install
homebrew, which is a very convenient package manager formacOS. Copy the following command in terminal and hit Enter:~$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Follow the instructions to get
brewready. When inputing your password, nothing will show up for security reasons. Just hit Enter when you’re finished. - When
brewis 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 - Next, check your
Rversion:~$ 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) -
If yours is
3.4, continue. Otherwise, upgrade it. - Enter the following into your terminal:
~$ brew uninstall --force cairo --ignore-dependencies ~$ brew cask install xquartz ~$ brew install --with-x11 cairo - Next, we need to tell
brewto change the way it wants to installgtk+. A text editor window will pop up. Note that if you are not familiar withvim, runexport EDITOR=emacsin terminal before the line above to force usingemacs, where you can use it as other common text editors.~$ brew edit gtk+Find where there is something like this:
def install args = [ "--disable-dependency-tracking", "--disable-silent-rules", "--prefix=#{prefix}", "--disable-glibtest", "--enable-introspection=yes", # "--disable-visibility", # "--with-gdktarget=quartz", "--with-gdktarget=x11", "--enable-x11-backend" ]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. - 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. -
Download the newest source file for
RGtk2from https://cran.r-project.org/web/packages/RGtk2/index.html. - 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.gzNote 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.)
-
When it finishes, open
XQuartzby usingspotlight search. -
A window that’s very similar to terminal will pop up. Type
rand hit enter to openR. - In
R, run:>> install.packages("https://togaware.com/access/rattle_5.0.14.tar.gz", repos=NULL, type="source") - Then try
rattlelibrary:>> library(rattle) >> rattle() Rattlewill show up and it may ask you whether to installXMLandcairoDevice. Click yes for both and you should be good to go now.