#' jobsPlot Creates a Chart showing the Total Estimates Jobs series for each County in Colorado
#'
#' Modified from ms_jobs January, 2018 AB
#'
#' Uses State Demography Office data to create a chart showing the timeseries of Total Estimated Jobs
#' (which means it includes Proprietors and Agricultural Workers) for a selected Colorado County
#'
#' @param fips is the fips code for the county being examined
#' @param ctyname This parameter puts the name of the county in the chart
#' @param maxyr The maximum year value, from CurYr
#' @param base is the abse text size for the ggplot2 object and codemog_theme()
#' @return ggplot graphic and data file
#' @export
#'
jobsPlot=function(fips, ctyname, maxyr,base=10){
jobs_data <- county_jobs(as.numeric(fips), 2001:maxyr) %>%
mutate(jobs=car::recode(totalJobs, "'S'=NA"),
jobs=round(as.numeric(jobs),0),
year=as.numeric(as.character(year)))
axs <- setAxis(as.numeric(jobs_data$jobs))
jobs_plot <- jobs_data %>%
ggplot(aes(x=year, y=as.numeric(jobs)))+
geom_rect(aes(xmin=2008, xmax=2010, ymin=-Inf, ymax=+Inf), fill=rgb(208, 210, 211, max = 255), alpha=.03)+
geom_rect(aes(xmin=2001, xmax=2002, ymin=-Inf, ymax=+Inf), fill=rgb(208, 210, 211, max = 255), alpha=.03)+
geom_line(color=rgb(0, 168, 58, max = 255), size=1.5)+
scale_x_continuous(breaks=c(2001:maxyr))+
scale_y_continuous(limits=c(axs$minBrk,axs$maxBrk), breaks=axs$yBrk, labels=comma)+
theme_codemog(base_size=base)+
labs(x="Year",
y="Jobs",
title= paste0("Total Estimated Jobs, 2001 to ",as.character(maxyr)),
subtitle = ctyname,
caption= paste0(captionSrc("SDO","") ,"\nNote: Grey shading represents beginning to bottom of U.S. recessions")) +
theme(plot.title = element_text(hjust = 0.5, size=18),
axis.text.x = element_text(angle=45,size=12),
axis.text.y = element_text(size=12))
outList <- list("plot" = jobs_plot, "data" = jobs_data)
return(outList)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.