Last active
December 25, 2015 17:29
-
-
Save smasunaga/7013197 to your computer and use it in GitHub Desktop.
How to make a chart of unemployment changes from 2009-2013
This file contains 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
read.csv("unemployment.csv") | |
unemployment <- read.csv("unemployment.csv") | |
data_for_2009 <- subset(unemployment, Year == 2009 & Month == 1) | |
data_for_2013 <- subset(unemployment, Year == 2013 & Month ==7) | |
data_for_2009 [,c("Area", "Unemployment.Rate")] | |
data_for_2013[,c("Area", "Unemployment.Rate")] | |
small_09 <-data_for_2009[,c("Area", "Unemployment.Rate")] | |
small_13 <-data_for_2013[,c("Area", "Unemployment.Rate")] | |
names(small_09)[2] <- "u_rate" | |
names(small_13)[2] <- "u_rate" | |
merged0913 <-merge(small_09, small_13, by = "Area") | |
merged0913$diff <-merged0913$u_rate13 - merged0913$u_rate09 | |
sort(merged0913$diff, decreasing = TRUE) | |
sorted_file <- sort(merged0913$diff, decreasing = TRUE) | |
max_difference <- max(sorted_file) | |
subset(merged0913, diff == min(sorted_file)) | |
subset(merged0913, diff == max(sorted_file)) | |
hist(sorted_file, xlab="Change in unemployment rate", ylab="Number of cities", main="Change in Unemployment Rate Across the U.S. (2009-2013", col="blue") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment