Last active
April 24, 2017 06:55
-
-
Save WalkerHarrison/33fc930d85fafd5c6a5613721d8f86b4 to your computer and use it in GitHub Desktop.
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
library(XML) | |
library(ggplot2) | |
library(ggmap) | |
library(RSocrata) | |
url_trees <- 'https://data.cityofnewyork.us/resource/nwxe-4ae8.csv' | |
url_zips <- 'http://zipatlas.com/us/ny/brooklyn/zip-code-comparison/median-household-income.htm' | |
trees <-read.socrata(url_trees) | |
trees <- subset(trees, boroname == 'Brooklyn') | |
trees$tree_dbh <- as.numeric(trees$tree_dbh) | |
neighborhoods <- readHTMLTable(url_zips, header=T, which=1, stringsAsFactors=F) | |
neighborhoods <- neighborhoods[complete.cases(neighborhoods), c(2,5,6)] | |
neighborhoods <- neighborhoods[-1, ] | |
names(neighborhoods) <- c("zipcode", "population", "income") | |
neighborhoods$population <- as.numeric(gsub("[$,]", "", neighborhoods$population)) | |
neighborhoods$income <- as.numeric(gsub("[$,]", "", neighborhoods$income)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment