Skip to content

Instantly share code, notes, and snippets.

@zhiyzuo
Created October 20, 2018 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhiyzuo/bd1ad00908421c7df5af19b8df747ccd to your computer and use it in GitHub Desktop.
Save zhiyzuo/bd1ad00908421c7df5af19b8df747ccd to your computer and use it in GitHub Desktop.

A not-so-complete guide to macOS setup for MSCI 3250: Analyzing Data for Business Intelligence


A side note: if you are not familiar with terminal, you can find a lot of related resources by googling. I found a video and a web page that may be helpful:


Setup

  1. Note that if you have rattle installed successfully on your mac, you can skip to step 4 directly.

  2. Install Homebrew by copying the following into your terminal and then hit enter:

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

    Follow the instructions shown in the standard output. You may need to hit enter for multiple times and enter your password to your computer. Note that when you type your password, there's no feedback in the terminal for safety reasons. Just hit enter when you're done inputing your password.

  3. After installation, we need to add some paths to your environment. In the following I provide a minimal .bash_profile that should be enough to make everything we need in this class work:

    # Add Homebrew `/usr/local/bin` and User `~/bin` to the `$PATH`
    #PATH=$HOME/bin:$PATH
    export PATH=/usr/local/bin:$PATH
    
    if [ -f $(brew --prefix)/etc/bash_completion ]; then
      . $(brew --prefix)/etc/bash_completion
    fi
    
    export PATH="/usr/local/opt/sqlite/bin:$PATH"
    export PATH="/usr/local/opt/openssl/bin:$PATH"
    export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
    export PATH="/usr/local/opt/icu4c/bin:$PATH"
    export PATH="/usr/local/opt/icu4c/sbin:$PATH"
    
    export PATH="/usr/local/opt/python/libexec/bin:$PATH"
    export PATH="/usr/local/opt/libpq/bin:$PATH"
    export PATH="/usr/local/opt/gdal2/bin:$PATH"
    export GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins
    export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
    export PKG_CONFIG_PATH="/usr/local/opt/gdal2/lib/pkgconfig"

    Copy this block of code into a text file and save it to your home folder and name it .bash_profile

  4. If you already have R/Rstudio working, please skip this step.

    Now, we need to install R/RStudio. Copy and paste the following lines into terminal and hit enter to install them.

    brew install r
    brew cask install rstudio

    After these finish, see if you can run RStduio and test some code to make sure they work.

  5. Now, to make choroplethr work, do the following in terminal:

    brew unlink gdal
    brew tap osgeo/osgeo4mac && brew tap --repair
    brew install gettext proj geos udunits gdal2
    brew link --force gdal2

    The following steps will be done in RStudio:

    install.packages('rgdal')

    If no errors show up for installing rgdal, we can move on. First check if sf package works by:

    library(sf)

    If not, do the following in RStudio:

    flags="LDFLAGS=-L/usr/local/opt/gettext/lib CPPFLAGS=-I/usr/local/opt/gettext/include"
    install.packages('sf', configure.args=flags)

    Finally, we should be able to install choroplethr:

    install.packages(c("choroplethr","choroplethrMaps"))

    If no errors show up, try the following code to see if you can get a map:

    library(choroplethr)
    data("df_pop_county")
    county_choropleth(df_pop_county) 
  6. To use RJDBC in R (to connect to database servers), we need to make rJava work first. For a more complete instructions to install rJava (for database connection), see here.

  7. To install rattle, check out this link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment