chooseCRANmirror(graphics = TRUE, ind=1)
knitr::opts_chunk$set(echo = TRUE)
setwd("~/Desktop/master courses/Applied/csv data")
unemployment=read.csv("unemployment.csv")
View(unemployment)
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
unemployment=unemployment %>% group_by(DATE) %>% summarise(UNRATE=sum(UNRATE))
## `summarise()` ungrouping output (override with `.groups` argument)
head(unemployment)
## # A tibble: 6 x 2
##   DATE      UNRATE
##   <fct>      <dbl>
## 1 1948/1/1     3.4
## 2 1948/10/1    3.7
## 3 1948/11/1    3.8
## 4 1948/12/1    4  
## 5 1948/2/1     3.8
## 6 1948/3/1     4
colnames(unemployment)[1] <- "Date"
unemployment$Date = as.Date(unemployment$Date, format = "%Y/%m/%d")
unemployment$UNRATE <- as.factor(unemployment$UNRATE)
library(ggplot2)
ggplot(unemployment, aes(x=Date, y=UNRATE)) +
     geom_point() + 
     scale_x_date(date_breaks="10 years",date_labels = "%Y")+
     xlab("date")+
     ylab("unemployment rate")+
     ggtitle("unemployment rate 1948-2018")+
     scale_y_discrete(breaks = seq(0, 10, by = 0.5))