For the climate change indicators, we will use publicly available data from the National Oceanic and Atmospheric Administration (NOAA). We will pull data on average, maximum and minimum temperature, and total precipitation by month by state from 1895. These values came from NOAA’s Climate at a Glance data. Please note that we chose the appropriate “parameter” on this webpage and then selected the “Download All Months/Years” option under the map for all four climate indicators.
Data Cleaning
disasters = read_csv("./data/DisasterDeclarationsSummaries2.csv") %>%
janitor::clean_names() %>%
mutate(disaster = factor(incident_type)) %>%
rename(
year = fy_declared) %>%
filter(year >= 1953 & year <= 2018) %>%
count(state, year, disaster) %>%
group_by(year, state) %>%
mutate(
n_state = sum(n)) %>%
group_by(year) %>%
mutate(
n_total = sum(n)) %>%
group_by(year, disaster) %>%
mutate(
n_type = sum(n)) %>%
rename("n_disaster_state" = "n")
Disaster Declarations Summary: This dataset was downloaded as a .csv file and imported into R. After cleaning the variable names, we renamed several variables, filtered to the appropriate year range, and kept information on state, disaster year, and disaster type. From there, we created several counts of disasters: by year, disaster type by year, per state by year, and disaster type by state by year. Some visualizations rely on count of disasters by region which was created as needed.
ave_temp = read_csv("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tavg.csv", skip = 3) %>%
janitor::clean_names() %>%
separate(date, into = c("year", "month"), sep = 4) %>%
mutate(
year = as.numeric(year),
state_code = setNames(state.abb, state.name)[location]) %>%
filter(year >= 1953 & year <= 2018) %>%
group_by(location, year) %>%
mutate(
mean_temp = mean(value)) %>%
dplyr::select(state_code, location, year, mean_temp) %>%
distinct() %>%
ungroup()
tmin = read_csv("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tmin.csv", skip = 3) %>%
janitor::clean_names() %>%
separate(date, into = c("year", "month"), sep = 4) %>%
mutate(
year = as.numeric(year),
state_code = setNames(state.abb, state.name)[location]) %>%
filter(year >= 1953 & year <= 2018) %>%
group_by(location, year) %>%
mutate(
min_temp = min(value)) %>%
dplyr::select(state_code, location, year, min_temp) %>%
distinct() %>%
ungroup()
tmax = read_csv("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-tmax.csv", skip = 3) %>%
janitor::clean_names() %>%
separate(date, into = c("year", "month"), sep = 4) %>%
mutate(
year = as.numeric(year),
state_code = setNames(state.abb, state.name)[location]) %>%
filter(year >= 1953 & year <= 2018) %>%
group_by(location, year) %>%
mutate(
max_temp = max(value)) %>%
dplyr::select(state_code, location, year, max_temp) %>%
distinct() %>%
ungroup()
precip = read_csv("https://www.ncdc.noaa.gov/cag/statewide/mapping/110-pcp.csv", skip = 3) %>%
janitor::clean_names() %>%
separate(date, into = c("year", "month"), sep = 4) %>%
mutate(
year = as.numeric(year),
state_code = setNames(state.abb, state.name)[location]) %>%
filter(year >= 1953 & year <= 2018) %>%
group_by(location, year) %>%
mutate(
total_precip = sum(value)) %>%
dplyr::select(state_code, location, year, total_precip) %>%
distinct() %>%
ungroup()
Climate Indicators: These datasets were downloaded from NOAA’s website directly and read as .csv files. Data on average temperature, minimum temperature, maximum temperature, and total precipitation were recorded monthly by state since 1953 (excluding Hawaii and Alaska). After pulling the data and cleaning variable names, we separated the year variable from their “yyyymm” formatted date variable. Next, data were grouped by state and year and summarized as follows:
Average Temperature The average temperature, in degrees Fahrenheit, by state across all 12 months per year was summarized.
Minimum Temperature: The minimum temperature, in degrees Fahrenheit, by state across all 12 months per year was summarized.
Maximum Temperature: The maximum temperature, in degrees Fahrenheit, by state across all 12 months per year was summarized.
Total Precipitation: The total precipitation, in inches, by state across all 12 months per year was totaled.
Final Dataset
final_data =
inner_join(ave_temp, precip, by = c("location" = "location", "year" = "year", "state_code" = "state_code")) %>%
inner_join(tmax, by = c("location" = "location", "year" = "year", "state_code" = "state_code")) %>%
inner_join(tmin, by = c("location" = "location", "year" = "year", "state_code" = "state_code")) %>%
full_join(disasters, by = c("year" = "year", "state_code" = "state"))
Data on climate change indicators across four datasets were inner-joined by state and year. This created a dataset with average temperature, maximum temperature, minimum temperature, and total precipitation by state and year. Then, this dataset was full-joined to the disaster dataset which had rows for each disaster by year and state.