1) 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 https://raw.githubusercontent.com/Homebrew/install/master/install)"
2) When brew is finished, copy the following commands 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
3) Next, check your R version:
R --version
4) If yours is 3.4, continue. IF NOT, upgrade it: https://cran.r-project.org/bin/macosx/ Please install Xquartz if you do not already have it: https://www.xquartz.org. After the installation. You must sign out then sign back in to use XQuartz Enter the following into your terminal:
brew uninstall --force cairo --ignore-dependencies
brew cask install xquartz
brew install --with-x11 cairo
5) Next, we need to tell brew to change the way it wants to install gtk+. A text editor window will pop up
export EDITOR=emacs
brew edit gtk+
6) Find the section similar to the paragraph below. Replace the whole chunk with this one.
You can copy and paste the paragraph using keyboard shortcuts ("command+c" then "command+v")into the code but you must delete the original paragraph manually ("delete" key). Then hit 'ctrl+x', 'ctrl+c', then ‘y’ to quit emacs.
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"
]
7) Now we can install gtk+ with the command:
brew install --build-from-source --verbose gtk+
8) 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
9) Download the newest source file for RGtk2 from https://cran.r-project.org/web/packages/RGtk2/index.html. Note that versions may vary depending on when you download the source file. Use the exact filename of the version you downloaded. (Tip: use tab to help autocomplete.)
cd ~/Downloads
R CMD INSTALL RGtk2_2.20.34.tar.gz
This is where your version number may differ^
10) When it finishes, open XQuartz by using spotlight search. A window that’s very similar to terminal will pop up. Type "r" and hit enter to open R. In R, run:
install.packages("https://togaware.com/access/rattle_5.0.14.tar.gz", repos=NULL, type="source")
If this does not work, try:
install.packages("rattle")
library(rattle)
rattle()
11) Rattle will show up and it may ask you to install XML and cairoDevice. Click yes for both and indicate "USA CA" and you will be all set!