Load dataset
library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
joined_data= read.csv("C:/Users/27977/Downloads/433/joined_data.csv")
Create the first graph
new=joined_data %>%
filter(state==("Wisconsin")|state==("California")|state==("New York"))%>%
filter(grepl("2021", year_mon))
new%>%
mutate(year_mon =ordered(year_mon, levels = unique(year_mon))) %>%
ggplot(aes(x=year_mon, y=unemployment_rate, group = state,colour=state))+
geom_line()+
theme_classic()+
xlab("Date")+
ylab("Unemployment Rate")+
ggtitle("Unemployment Ratio of Selected States in US")+
theme(legend.title = element_text(size=4),legend.text=element_text(size=4))
## Warning: Removed 6 row(s) containing missing values (geom_path).
# ggplot(aes(x=year_mon, y=unemployment_rate, group = state,colour=state))+
# geom_line()+
# theme_classic()+
# xlab("Date")+
# ylab("Unemployment Rate")+
# ggtitle("Unemployment Ratio of Each State in US")+
# theme(legend.title = element_text(size=4),legend.text=element_text(size=4))
# scale_x_discrete(limits = c("Dec 2020","Jan 2021",))
The first graph plots the unemployment ratio of selected states in the US during the covid over time. The unemployment rate has risen to an unprecedented level because of the pandemic, causing more than just the finance problem all over the world. By making this plot of the unemployment ratio, we could easily observe when the unemployment problem arose during the pandemic, at what time it arrived at a peak, and how the policy might had an influence on the unemployment ratio. To differentiate each state visually and observe the continual change across time, I used geom_line with different colors to each state, then used scale_x_discrete to avoid overlap of the x label and used theme to reduce the size of the legend.
Create the second graph
joined_data %>%
ggplot(aes(x=Bachelor_or_Higher_Pct, y=reorder(state,Bachelor_or_Higher_Pct),fill=state))+
geom_col()+
labs(title = "Bachelor or higher degree rate of each state in the US",x="rate",y="state")+
theme(panel.grid = element_blank(),legend.title = element_text(size=4),legend.text=element_text(size=4),legend.position="none")
The second graph shows the rate of bachelor or higher degree of each state in the US. It is notable that Massachussts and Colorado have significantly higher rates of bachelor or higher degree compared to other states. To easily identify and compare the ratio of each state, I used geom_col with different colors for each state and sorted the ratio by using the reorder parameter, then used theme to customize the size of the legend.