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(idbr) | |
library(ggplot2) | |
library(dplyr) | |
library(gganimate) | |
library(animation) | |
idb_api_key("Your key goes here") | |
male <- idb1('NI', 1990:2050, sex = 'male') %>% | |
mutate(POP = POP * -1, |
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(idbr) | |
library(dplyr) | |
library(ggplot2) | |
library(tidyr) | |
library(countrycode) | |
library(gganimate) | |
library(tweenr) | |
ctrys <- countrycode(c('South Africa', 'Botswana', 'Lesotho', 'Namibia', 'Zimbabwe', 'Swaziland'), | |
'country.name', 'fips104') |
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(tigris) | |
us_states <- unique(fips_codes$state)[1:51] | |
us_places <- rbind_tigris( | |
lapply( | |
us_states, function(x) { | |
places(state = x, cb = TRUE) | |
} | |
) |
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
# Write to a shapefile for loading into CartoDB | |
writeOGR(tad_merged, dsn = ".", layer = 'fw_parcels', | |
driver = 'ESRI Shapefile', overwrite_layer = TRUE) |
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
summary(tad_merged$valsqft) | |
# Min. 1st Qu. Median Mean 3rd Qu. Max. | |
# 0.00 5.42 12.06 16.07 23.03 6345.00 | |
quantile(tad_merged$valsqft, probs = seq(0, 1, 1/7)) | |
# 0% 14.28571% 28.57143% 42.85714% 57.14286% 71.42857% 85.71429% 100% | |
# 0.00 2.97 6.24 9.83 15.05 21.55 27.91 6344.93 |
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
# Merge the TAD data to the parcels based on a common ID, and remove un-matched records | |
tad_merged <- geo_join(parcels, tad_sub, 'TAXPIN', 'GIS_Link', how = 'inner') | |
# Drop parcels with an area of 0, and calculate a "value/square foot" column | |
tad_merged <- tad_merged[tad_merged$CALCULATED != 0, ] | |
# Calculate value/square foot (converting acres to square feet) | |
tad_merged$valsqft <- round(tad_merged$Total_Value / (tad_merged$CALCULATED * 43560), 2) |
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
# Load in the data with readOGR (warning: slow) | |
parcels <- readOGR(dsn = ".", layer = 'tad5ft', stringsAsFactors = FALSE) | |
# Drop undeveloped parcels and unneeded columns | |
parcels <- parcels[parcels$PARCELTYPE != 2, ] | |
parcels@data <- parcels@data[c('TAXPIN', 'CALCULATED')] |
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
# Set your working directory in RStudio to your data/script directory | |
# Session > Set Working Directory > To Source File Location | |
# If necessary, first run | |
# install.packages(c('rgdal', 'readr', 'dplyr', 'tigris', 'ggplot2', 'scales')) | |
library(rgdal) # For loading spatial data | |
library(readr) # For loading tabular data | |
library(dplyr) # For processing tabular data | |
library(tigris) # For joining spatial and tabular data |
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(idbr) | |
library(ggplot2) | |
library(animation) | |
library(dplyr) | |
library(gganimate) | |
idb_api_key("Your Census API key goes here") | |
male <- idb1('IN', 2000:2050, sex = 'male') %>% | |
mutate(POP = POP * -1, |
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(tigris) | |
library(rgeos) | |
library(stringr) | |
library(leaflet) | |
# Pull the ZCTAs | |
zips <- zctas(cb = TRUE, starts_with = c('75', '76')) | |
plot(zips) |