Skip to content

Instantly share code, notes, and snippets.

@hepplerj
Created June 15, 2016 20:24
Show Gist options
  • Save hepplerj/9c7ea4cdae853e745100905269c5e0bb to your computer and use it in GitHub Desktop.
Save hepplerj/9c7ea4cdae853e745100905269c5e0bb to your computer and use it in GitHub Desktop.
Data prep for DHSI
# Superfund sites CSV
calif_superfund_sites <- read.csv("./data/calif_superfund_sites.csv")
# We'll clean up the Superfund data a bit, selecting only
# the columns we want to keep.
calif_superfund_sites <- calif_superfund_sites %>%
select(NAME, CITY,STATE,ZIP,LONGITUDE,LATITUDE,STATUSDATE,HRS_SCORE)
# Let's filter out California sites.
calif_superfund_sites <- subset(calif_superfund_sites,
STATE %in% "CA")
# Convert the date into an R friendly version.
calif_superfund_sites$date <- as.Date(calif_superfund_sites$STATUSDATE, "%m/%d/%Y")
# Lowercase the variable names.
calif_superfund_sites <- setNames(calif_superfund_sites, tolower(names(calif_superfund_sites)))
# Extract the year to a new column
library(lubridate)
calif_superfund_sites$year <- year(calif_superfund_sites$date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment