Due by 11:59 PM on Monday, October 16, 2017

Complete these tasks in an R Markdown file and e-mail me a PDF of the final compiled document. Here’s the typical starter file. As always, I recommend saving it within an RStudio project. Make sure the final output is as clean and warning/message free as possible.

Task 1: Reflection memo

Write a 500-word memo about the assigned readings for this week. You can use some of the prompt questions there if you want:

As you write the memo, also consider these central questions:

Task 2: Make a map

This task is not very code intensive—I’m giving you all the code!

That said, there’s still some work you have to do.

Step 1: Install extra software and R packages

  1. Plotting geographic stuff with ggplot is crazy easy nowadays with the new sf package, which works nicely within the tidyverse paradigm. However, it’s so new that the CRAN version of ggplot doesn’t have geom_sf() and other geographic plotting layers. You must install the development version of the package from GitHub. Doing this makes your computer compile the package from its source code and requires some fancy software to work.
    • If you’re using Windows, download and install Rtools (currently Rtools34.exe).
    • If you’re using macOS, open Terminal and type this:

        xcode-select --install
      A software update popup window should appear that will ask if you want to install command line developer tools. Click on “Install” (you don’t need to click on “Get Xcode”)
  2. Once you install those tools, make sure you install the devtools package in R (using the “Packages” panel, like normal), and then run this in your R console:

    This will download, compile, and install the latest development version of ggplot. It’ll take a while—go eat something.
  3. Using the “Packages” panel in RStudio, install these packages: sf, maps, maptools, and rgeos
  4. Final step for macOS people only: R doesn’t do all the geographic calculations by itself—it relies on a few pieces of standalone software behind the scenes. When people on Windows install sf, those pieces of software should be installed automatically. This doesn’t happen on macOS, so you have to install them manually. The easiest way to do this is with Terminal. Here’s what you have to do:
    1. Open Terminal
    2. If you haven’t already, go to, copy the big long command under “Install Homebrew” (starts with /usr/bin/ruby -e "$(curl -fsSL...), paste it into Terminal, and press enter. This installs Homebrew, which is special software that lets you install Unix-y programs from the terminal. You can install stuff like MySQL, Python, Apache, and even R if you want; there’s a full list of Homebrew formulae here.

    3. Type this line in Terminal to install gdal, geos, and proj:

       brew install gdal geos proj
    4. Wait for a few minutes—go eat something else.

Step 2: Actually make a map

In last week’s assignment, you looked at the percentage of different countries’ populations with access to the internet. This week, you’ll use the same data to map the level of internet access around the world in 2015.

I provide a full working example for you. Rather than just copying and pasting the code and knitting, though, I want you to run each line in RStudio and see what’s going on. In the starter Rmd file, I’ve included a list of code pieces you need to explain.

You need this data:

The only strange, arcane thing in the code is coord_sf(crs = st_crs(XXXX)). This changes the coordinate system (or projection) for the map.TECHNICALLY coordinate systems and projection systems are different things, but I’m not a geographer and I don’t care that much about the nuance.

Recall from your reading that there are lots of different ways to project maps onto a flat surface. “CRS” refers to “coordinate reference system” and lets you specify a projection. There are standard indexes of more than 4,000 of these projections (!!!) at Here are some common ones:

Alternatively, instead of using these index numbers, you can use any of the names listed at proj.4, such as:

Here we go! First we load the internet users data:

Then we load the geographic data and combine it with the internet data:

## Reading layer `ne_50m_admin_0_countries' from data source `/Users/andrew/Sites/sites/dataviz/static/data/ne_50m_admin_0_countries/ne_50m_admin_0_countries.shp' using driver `ESRI Shapefile'
## Simple feature collection with 241 features and 63 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -89.99893 xmax: 180 ymax: 83.59961
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs

Finally, we plot the map:

Task 3: Illustrator introduction

Step 1: Quickly get familiar with Illustrator (or Inkscape)

Watch and work through these tutorials (you can speed them up to 1.5× or 2× if you want):

These are all specific to Illustrator, but the same principles apply to Inkscape (though tools and options will have different names). I recommend learning Illustrator now while you have free access to it, and then in the future when you won’t necessarily have access to Adobe’s Creative Cloud, you’ll be able to translate your skills to Inkscape.

Step 2: Make something with Illustrator

  1. Use ggsave() to save your map of internet users as a PDF.
  2. Place the map in a new document in Illustrator.
  3. Enhance it with annotations, lines, shapes, etc. Make it fancy. But also follow the principles of CRAP and don’t go crazy.

  4. Export the completed graphic as a PDF and PNG.