pacman::p_load(tidyverse, lubridate, stringr)
social_security <- read_csv("ssadisability.csv")
glimpse(social_security) view(social_security) attach(social_security)
social_security_longer <- pivot_longer(social_security, !Fiscal_Year, names_to = "month", values_to = "applications") view(social_security_longer)
unique(social_security_longer$month)
social_security_longer <- social_security_longer %>% separate(month, c("month", "application_method"), sep = "_") view(social_security_longer)
unique(social_security_longer$month)
social_security_longer <- social_security_longer %>% mutate(month = substr(month, start = 1, stop = 3)) view(social_security_longer)
unique(social_security_longer$Fiscal_Year)
social_security_longer <-social_security_longer %>% mutate(Fiscal_Year = str_replace(Fiscal_Year, pattern = "FY", replacement = "20")) view(social_security_longer)
social_security_longer$date <- dmy(paste('01', social_security_longer$month, social_security_longer$Fiscal_Year)) view(social_security_longer)
social_security_longer <- social_security_longer %>% mutate(Fiscal_Year=as.numeric(Fiscal_Year)) %>% mutate(Fiscal_Year=ifelse(month(date)>=10, Fiscal_Year-1, Fiscal_Year)) %>% mutate(date=dmy(paste("01", month, Fiscal_Year)))
view(social_security_longer)
social_security_longer <- social_security_longer %>% rename(Fiscal_Year = Fiscal_Year, Month = month, Application_methods = application_method, Applications = applications, Date = date)
view(social_security_longer) summary(social_security_longer) attach(social_security_longer)
social_security_longer <- social_security_longer %>% select(-Fiscal_Year, -Month) %>% mutate(Application_methods = as.factor(Application_methods)) view(social_security_longer) summary(social_security_longer)
social_security <- pivot_wider(social_security_longer, names_from = Application_methods, values_from = Applications) %>% select(Date, Internet, Total) attach(social_security) view(social_security)
social_security <- social_security %>% mutate(Online_Percentage = Internet / Total * 100)
view(social_security)
ggplot(data = social_security, mapping = aes(x = Date, y = Online_Percentage)) + geom_point()