Scratch Work
I use this Rmd to work out my coding since I’m more familiar with Rmd.
Found Issues: - ggplot is not rendering in Shiny Why? - Not sure yet. No error given but shows blank plot. This might be dat$Dat column classified as chr or Posixt. I already added in code to convert to as.date but it’s not reading it?? - ylab in ggplot
To get done this week: -Fix issues, once I get this issue solved, the rest will be easier - Currently working on Tables. I found new functions for the tables and will cbind the others. -I want to divide State, County and Metro. - Some aesthetics: Bold, Underline, …etc - Add multiple selected Area Names to same ggplot
as.date wasn’t working.library(ggplot2)
library(lubridate)
##
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
##
## date, intersect, setdiff, union
library(readxl)
dat <- read_excel("~/Desktop/Stat 128/Local Area Employment/Employment/Local_Area_Unemployment_Statistics__LAUS_.xlsx")
#p = dat[order(as.Date(dat$Date, format="%Y/%m/%d")), ]
# dat$Date <- as.Date(dat$Date , format = "%m/%d/%Y")
# p = dat[order(dat$Date ), ]
dat$Date <- ymd(dat$Date)
p2 = dat[c(dat$Area_Name == "California"), ]
p3 = p2[p2$Date >= "1990-01-01" & p2$Date <= "2020-01-01", ]
p4 = p3[, c("Date", "Labor_Force", "Unemployment", "Employment", "Unemployment_Rate")]
g = ggplot(p4, mapping = aes(Date, Labor_Force)) + geom_line(mapping = aes(Date, Unemployment), color = "blue")
print(g)
sum = aggregate(list(Total_Unemploy = p3$Unemployment), by = list(Year = p3$Year), FUN=sum)
sum
## Year Total_Unemploy
## 1 1990 20994700
## 2 1991 28022900
## 3 1992 34153500
## 4 1993 34695200
## 5 1994 31460600
## 6 1995 28744100
## 7 1996 26918700
## 8 1997 24124600
## 9 1998 23032300
## 10 1999 20668900
## 11 2000 20038000
## 12 2001 22326700
## 13 2002 27556200
## 14 2003 28209200
## 15 2004 25894700
## 16 2005 22721600
## 17 2006 20790300
## 18 2007 23047700
## 19 2008 31823300
## 20 2009 48766900
## 21 2010 53808300
## 22 2011 51773000
## 23 2012 46126800
## 24 2013 39986100
## 25 2014 33687500
## 26 2015 28013100
## 27 2016 25014700
## 28 2017 22058500
## 29 2018 19695600
## 30 2019 18825000
## 31 2020 1593300
#Need to add Avg Unemplo_Rate
g2 = ggplot(data = sum, mapping = aes(x = Year, y = Total_Unemploy)) + geom_line()
print(g2)