Created
June 20, 2013 14:18
-
-
Save corynissen/5823114 to your computer and use it in GitHub Desktop.
geom_hex question
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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