Skip to content

Instantly share code, notes, and snippets.

@corynissen
Created June 20, 2013 14:18
Show Gist options
  • Select an option

  • Save corynissen/5823114 to your computer and use it in GitHub Desktop.

Select an option

Save corynissen/5823114 to your computer and use it in GitHub Desktop.
geom_hex question
# 4ijn-s7e5 is food inspections in Chicago data set 2010 to present
# may take a minute or two...
df <- read.csv("http://data.cityofchicago.org/views/4ijn-s7e5/rows.csv",
stringsAsFactors = F)
names(df) <- tolower(names(df))
# we don't want missing values in lat or lon
df <- subset(df, !is.na(longitude) & !is.na(latitude))
# let's look at complaints / food poisonings...
df <- subset(df, inspection.type %in% c("Complaint", "Short Form Complaint", "Suspected Food Poisoning"))
# business licenses 2006 to present... r5kz-chrr
# may take a minute or two...
lic <- read.csv("http://data.cityofchicago.org/views/r5kz-chrr/rows.csv",
stringsAsFactors = F)
names(lic) <- tolower(names(lic))
lic <- subset(lic, license.description=="Retail Food Establishment")
# get rid of duplicate addresses
lic <- subset(lic, !duplicated(address))
ggplot(df) + geom_hex(aes(x=longitude, y=latitude), bins=30) + scale_fill_gradient(low="black", high="blue")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment