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:
-
Note that if you have
rattle
installed successfully on your mac, you can skip to step 4 directly. -
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.
-
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/[email protected]/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
-
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.
-
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 ifsf
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)
-
To use
RJDBC
in R (to connect to database servers), we need to makerJava
work first. For a more complete instructions to installrJava
(for database connection), see here. -
To install
rattle
, check out this link