October 24, 2016

Side Note

You quickly compute proportions without creating two separate tables (one for numerator and one for denominator) by group_by(), but then instead of summarise(), use a mutate().

library(dplyr)
library(ggplot2)

mtcars %>% 
  group_by(cyl, am) %>% 
  summarise(n=n()) %>% 
  group_by(cyl) %>% 
  mutate(
    prop = n/sum(n),
    prop = round(prop, 2)
  )

USA Boundaries

Run the following:

library(USAboundaries)
library(sp)
states_1840 <- us_states("1840-03-12")
plot(states_1840, axes=TRUE)
title("U.S. state boundaries on March 3, 1840")

USA Boundaries

sp Package

The sp package has tools for loading/storing vector data in R. sp stands for SpatialPolygons

Drawing