-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp.R
More file actions
1505 lines (1205 loc) · 117 KB
/
app.R
File metadata and controls
1505 lines (1205 loc) · 117 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# This is a Shiny web application. You can run the application by clicking
# the 'Run App' button above.
#
# An explorer of UI data, which can be downlaoded from here: https://oui.doleta.gov/unemploy
# This data concerns the administration of the UI program in each state.
# Specifically, this focuses on data regarding payment and decision timelapses, to ensure that
# states are holding up their end of the bargain in promptly paying claimants or at least adjudicating their
# cases promptly
# Made by Michael Hollander of Community Legal Services, 1/2017
# shinyapps.io uses calls to 'library' to know what the environment for the
# app should be.
library(config)
library(V8)
library(jqr)
library(shiny)
library(lubridate)
library(DT)
library(ggplot2)
library(scales)
library(shinycssloaders)
library(tidyverse)
library(geojson)
library(gghighlight)
library(ggrepel)
#library(protolight)
library(geojsonio)
library(leaflet)
library(arrow)
source("helper.R")
# for testing
# input <- list(range = as.Date(c("2008-01-01", "2020-05-30")), state = "PA")
# read in the df of data that we need
stored_data_location <- file.path(get("DATA_DIR"), "unemployment_data.parquet")
unemployed_df <- arrow::read_parquet(stored_data_location)
maxDate <- max(unemployed_df$rptdate)
minDate <- min(unemployed_df$rptdate)
states <- sort(unique(unemployed_df$st))
states <- states[states != "US"]
pua_earliest <- ymd("2020-01-31")
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("Unemployment Insurance Data Explorer"),
h4("Unemployment data, visualized and available for download."),
# Sidebar with a file input
sidebarLayout(
sidebarPanel(
# the input that allows a state to be chosen
selectInput("state",
label = "Choose a state",
choices = states,
selected = sample(states, 1)), #select a random state
shinyWidgets::sliderTextInput(
inputId = "range",
label = "Years to View:",
choices = zoo::as.yearmon(seq.Date(floor_date(minDate, "month"), floor_date(maxDate, "month"), by = "month")),
selected = zoo::as.yearmon(c(maxDate - years(10), maxDate)),
hide_min_max = TRUE,
#grid = TRUE,
width = "100%"
),
# the list of data to view; shoudl rethink how to easily define new data sets rather than
# having to handcode each dataset here and in 10 other places
tags$style("#viewData {font-size:90%;}"),
selectInput("viewData",
label = 'Select Data to View',
size=37, selectize=FALSE,
choices = c("Basic UI Data" = "basicUI_claims",
"--Weeks Claims/Compensated" = "basicUI_compensated",
"--Weekly Initial and Continued Claims" = "basicWeeklyClaims",
"--Monthly UI Payments" = "monthlyUI",
"--Init. Payments / Claims" = "basicUI_payment_rate",
"--Workshare Initial Claims" = "basicUI_workshare_initial",
"--Workshare Continued Claims" = "basicUI_workshare_continued",
"--Unemployment Rate (SA)" = "uirate",
"Demographics: Race" = "demographics_race",
"--Demographics: Ethnicity" = "demographics_ethnicity",
"--Demographics: Sex" = "demographics_sex",
"--Demographics: Age" = "demographics_age",
"Recipiency Rate" = "recipRate",
"--Recipiency Rate Breakdown" = "recipBreakdown",
"Pandemic Unemployment Assistance" = "puaData",
"--PUA Basic Claims Data" = "puaClaims",
"--PUC $600 Payments" = "pucClaims",
"Timeliness of First Payments" = "firstPay",
"Timeliness of Lower Authority Decisions" = "lowerAuthority",
"Timeliness of Higher Authority Decisions" = "higherAuthority",
"Overpayment vs Recovery" = "overvRecovery",
"--Overpayment Balance/Annual UI Payments" = "overvPayments",
"--Fraud vs Non Fraud Overpayents" = "fraudvNon",
"--Tax Program Overpayment Recoveries" = "TOPS",
"Non-Monetary Denials (Per Determination)" = "nonMonDen",
"--Non-Monetary Denials (Per Initial Claim)" = "nonMonDenInitClaims",
"--Separation Denial Breakdown" = "nonMonSep",
"--Separation Denial Rates (Per Determination)" = "nonMonSepRate",
"--Separation Denial Rates (Per Initial Claim)" = "nonMonSepRateInitClaims",
"--Non-Separation Denial Breakdown" = "nonMonNonSep",
"--Non-Separation Denial Rates (Per Determination)" = "nonMonNonSepRate",
"--Non-Separation Denial Rates (Per Initial Claim)" = "nonMonNonSepRateInitClaims",
"Monetary Determinations" = "monetaryDeterminations",
"--Percent Receiving Max Weekly Benefit" = "monetaryDeterminations_max_weekly",
"--Average Weeks Duration" = "monetaryDeterminations_average_weeks"),
# the default selected is the recipiency Rate, but this coudl be anythign
selected = "basicUI_claims"),
# allows for a constant y axis on the main charts, which allows state to state
# comparisons to be made.
checkboxInput("constant_y_axis",
label="Constant y axis? (makes comparisons easier)",
value=FALSE),
tags$img(src="CLS-Logo_TCF.png", width="100%")
# the width of the sidebar panel
, width=4),
# the main panel
mainPanel(
# specify the different panels and layouts
tabsetPanel(
# the main panel; has a plot, data, and a download data button
tabPanel("Data",
withSpinner(plotOutput("uiplot")),
downloadButton('downloader', 'Download Data'),
dataTableOutput("uidata")
),
# the 50-state on one plot tab
tabPanel("50-State Overlay (one plot)", withSpinner(plotOutput("fiftyStatePlot"))),
# the 50-state on different plots tab
tabPanel("50-State Comparison (many plots)", withSpinner(plotOutput("smplot", height="900px"))),
# chloropleth map
tabPanel("Map",withSpinner(leafletOutput("uimap"))),
# the about page, which may need to be rewritten
tabPanel("About", br(),
h3("About This Page"),
p("The goal of the website is to make the wealth of unemployment related data provided by the US Department of Labor and the Bureau of Labor Statistics more accessible to the general public. Much of the information on the website is simply a visualization of the data available from the USDOL for a specific state and time period, however other metrics involve calculations combining multiple data points. If you have suggestions for further measures to put on this page, please email ", a(href="mailto:hollander@gmail.com", "Michael Hollander (hollander@gmail.com.")),
h3("Using The Website"),
p("On the left-hand side of the page one can choose:",
tags$ul(
tags$li(tags$b("A metric to view")),
tags$li(tags$b("A state to view data on")),
tags$li(tags$b("The years of data to view"), glue::glue("(overall data ranges from {format(minDate, '%b/%Y')} to {format(maxDate, '%b/%Y')}, however some metrics are only avaible for subsets of that time (e.g. Pandemic Unemployment Assistance is only available starting in 2020)")),
tags$li(tags$b("Whether to maintain a 'constant y axis.'"), "A constant y axis means that whether you view California or Montana, the scale of the y-axis will maintain the same range for each chart. This makes it easier to compare states to each other, but may may certain measures difficult to view for some states. For example, it would not be easy to view Montana's initial claims numbers with a constant y-axis because the volume of claims in Montana is so far below the largest states' claims.")
)),
p("The main part of the page displays the metric selected for the state in question in one of four different formats depending on the selection made at the top of the screen. The latter three data representations are only able to show one piece of each metric (e.g. weekly initial claims) rather than the entire metric (e.g. first payments and exhaustions are left out):",
tags$ul(
tags$li(tags$b("A direct look at the UI Data."), "The direct look at the UI data shows a graph at the top (with recession shading), a link to download the requested data in csv (excel) format, and a sortable/filterable table at the bottom."),
tags$li(tags$b("A single-plot 50-state overlay."), "The single-plot comparison shows a single graph with a line for each state on the graph. The state selected on the left is highlighted to allow for a comparison versus the rest of the US."),
tags$li(tags$b("A multi-plot 50-state comparison."), "The multi-plot comparison, also called a 'small multiple' chart shows the same metric for each state, but in 50 separate graphs. Each graph shows both the metric being measured as well as the US average (the dotted line). Trends across states can be easily spotted with this graph. By checking and unchecking the 'constant y-axis' box, absolute and relative comparisons can be more easily made."),
tags$li(tags$b("A map."), "A choropleth map distinguishing the states by color-coding them based on the value of the metric in question in the most recent month selected in the left-hand side."))),
h3("Technical Stuff"),
p("This application was created by", a(href='mailto:hollander@gmail.com', "Michael Hollander"), "formerly of", a(href='https://clsphila.org', "Community Legal Services"), "and is maintained by", a(href='https://tcf.org', "The Century Foundation."), "You can find the", a(href='https://github.com/tcf-ui-data/ui-data-explorer', "code for this page on Github."), "The DOL Data can be found", a(href = "https://oui.doleta.gov/unemploy/DataDownloads.asp", "on the Downloads Page"), "for the DOL's Employment and Training Administration. BLS data is accessible through", a(href='https://fred.stlouisfed.org/', "FRED/the Federal Reserve Bank of St. Louis.")),
p("This product uses the FRED® API but is not endorsed or certified by the Federal Reserve Bank of St. Louis."),
p("By using this application, you are also bound by FRED® API ", a(href="https://research.stlouisfed.org/docs/api/terms_of_use.html", target="_blank", "terms of use."))
),
tabPanel("Glossary", br(),
h3("Glossary"),
tags$ul(
tags$li(tags$b("Weeks Compensated:"), 'An unemployment payment to a worker for a week of partial or total unemployment is considered a “compensated week.”'),
tags$li(tags$b("Initial Claims:"), 'New application for unemployment benefits or to restart unemployment benefits after a subsequent period of unemployment benefits within a benefit year.'),
tags$li(tags$b("Continued Claims or Insured Employment:"), 'Ongoing claims for unemployment benefits including weeks that are paid, and weeks that are pending or serving a disqualification.'),
tags$li(tags$b("Worksharing:"), 'Worksharing, also known as short-time compensation (STC), allows employers to reduce hours of work for employees rather than laying off workers.'),
tags$li(tags$b("Demographics:"), 'Percent of all continuing claims dispersed to members of different demographic groups.'),
tags$li(tags$b("Recipiency Rate:"), 'The proportion of jobless workers receiving benefits from state and federal programs.'),
tags$li(tags$b("Pandemic Unemployment Assistance (PUA):"), 'CARES Act program that expanded states’ ability to provide unemployment insurance for many workers impacted by the COVID-19 pandemic, including for workers who are not ordinarily eligible for unemployment benefits, including independent contractors, self-employed, students and youth, and others who may be unable to prove prior-year income.', a(href='https://oui.doleta.gov/unemploy/pdf/PUA_FactSheet.pdf', "Read more.")),
tags$li(tags$b("Federal Pandemic Unemployment Compensation (FPUC, or PUC):"), 'CARES Act program that automatically provides an additional $600 in federally funded benefits per week for the weeks ending April 4, 2020 through the week ending July 25, 2020.'),
tags$li(tags$b("Timeliness of First Payments:"), 'Percent of all 1st payments made within 14/21/35 days after the week ending date of the first compensable week in the benefit year.'),
tags$li(tags$b("Timeliness of Lower Authority Appeals:"), 'The sum of the ages, in days from filing, of all pending Lower Authority Appeals divided by the number of Lower Authority Appeals.'),
tags$li(tags$b("Timeliness of Higher Authority Appeals:"), 'The sum of the ages, in days from filing, of all pending Higher Authority Appeals divided by the number of Higher Authority Appeals.'),
tags$li(tags$b("Overpayment Balance:"), 'The amount of benefits required to return due to error, fraud, or ineligibility.'),
tags$li(tags$b("Tax Program Overpayment Recoveries:"), 'Unemployment insurance overpayments recovered by a reduction of tax refunds.'),
tags$li(tags$b("Non-Monetary Denials:"), 'Denials due to eligibility issues other than the amount earned.'),
tags$li(tags$b("Separation Denials:"), 'Denials due to eligibility related to the reason that an individual lost a job'),
tags$li(tags$b("Non-Separation Denials:"), 'Denials due to eligibility issues including whether an applicant is available for work, refused a job offer, or failed to search for work.')
)
)
)
)
),
# a row at the bottom with links, etc...
fluidRow(
hr(),
HTML("This application was created by <a href='mailto:hollander@gmail.com'>Michael Hollander</a>, formerly of <a href='https://clsphila.org' target='_blank'>Community Legal Services</a> and is maintained by <a href='https://tcf.org' target='_blank'>The Century Foundation</a>.You can find the <a href='https://github.com/tcf-ui-data/ui-data-explorer' target='_blank'>code for this page on Github</a>. All of the data for this website comes from <a href='https://oui.doleta.gov/unemploy/DataDownloads.asp' target='_blank'>the US Department of Labor</a> and the U.S. Bureau of Labor Statistics, through <a href='https://fred.stlouisfed.org/' target='blank'>FRED/the Federal Reserve Bank of St. Louis</a>.")
)
)
# Define server logic required to draw page
server <- function(input, output) {
makeReactiveBinding("date_filter_start")
makeReactiveBinding("date_filter_end")
toListen <- reactive({list(input$range, input$viewData)})
observeEvent(toListen(), {
date_filter_start <<- get_last_day_of_month_from_range(input$range[1])
date_filter_end <<- get_last_day_of_month_from_range(input$range[2])
# set the start and end date to no earlier than the 1/31/2020 if we selected PUA
if(input$viewData %in% c("puaData", "puaClaims", "pucClaims")) {
if(date_filter_start < pua_earliest) date_filter_start <<- pua_earliest
if(date_filter_end < pua_earliest) date_filter_end <<- date_filter_start + months(4)
}
})
# render the plot
output$uiplot <- renderPlot({
# get start and end date filters
df <- unemployed_df %>%
filter(st == input$state,
rptdate >= date_filter_start,
rptdate <= date_filter_end)
if (input$viewData == "monthlyUI")
{
metric_filter = c("total_federal_compensated_mov_avg", "total_state_compensated_mov_avg")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, labels = metric_filter, ordered = TRUE))
uPlot <- getRibbonPlot(df, xlab = "Date", ylab = "Total Paid",
caption = "12-month moving average of UI paid per month in both regular and federal UI programs.\nNote that 'regular UI' includes state UI, UFCE, and UCX. Federal programs include EB, and the various EUC programs that have been enacted.",
title = glue::glue("{input$state} Monthly UI Payments from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("total_state_compensated_mov_avg","total_federal_compensated_mov_avg"),
labels=c("Regular Programs","Federal Programs")) +
scale_y_continuous(labels = label_number(scale = 1/1000000, prefix = "$", suffix = "M"))
# adjustment for finding the max height of the graph
metric_filter = c("total_compensated_mov_avg")
}
else if (input$viewData == "basicWeeklyClaims")
{
metric_filter = c("weekly_initial_claims", "weekly_continued_claims")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 539, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Weekly Initial and Continued Claims Claims from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Initial Claims", "Continued Claims")) +
scale_y_continuous(labels = comma)
# adjustment for finding the max height of the graph
metric_filter = c("weekly_continued_claims")
}
else if (input$viewData == "basicUI_claims")
{
metric_filter = c("monthly_initial_claims", "monthly_first_payments", "monthly_exhaustion" )
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 5129, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Monthly State Claims, Payments and Exhaustion Eligibility from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= c("monthly_initial_claims", "monthly_first_payments", "monthly_exhaustion" ),
labels=c("Initial Claims", "First Payments", "Exhaustion")) +
scale_y_continuous(labels = comma)
# adjustment for finding the max height of the graph
metric_filter = c("monthly_initial_claims")
}
else if (input$viewData == "basicUI_compensated")
{
metric_filter = c("monthly_weeks_compensated", "monthly_partial_weeks_compensated")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 5129, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Monthly Compensation (state), Weeks Compensated from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Weeks Compensated", "Partial Weeks Compensated")) +
scale_y_continuous(labels = comma)
# adjustment for finding the max height of the graph
metric_filter = c("monthly_weeks_compensated")
}
else if (input$viewData == "basicUI_payment_rate")
{
metric_filter = c("monthly_first_payments_as_prop_claims_12_mo_avg")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 5129, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} 12-mo Moving Average of First Payments as a Proportion of Initial Claims\nfrom {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("12-mo Moving Average of Monthly Payments as a Proportion of Initial Claims")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "basicUI_workshare_initial")
{
metric_filter = c("workshare_initial_claims")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA aw5159, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Monthly Workshare Initial Claims from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Initial Claims")) +
scale_y_continuous(labels = comma)
}
else if (input$viewData == "basicUI_workshare_continued")
{
metric_filter = c("workshare_continued_claims")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA aw5159, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Monthly Workshare Continued Claims from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Continued Claims")) +
scale_y_continuous(labels = comma)
}
else if (input$viewData == "demographics_race")
{
metric_filter = c("demographic_race_prop_native_american_alaskan", "demographic_race_prop_asian_pacific_islander", "demographic_race_prop_unk",
"demographic_race_prop_black", "demographic_race_prop_white")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, levels = metric_filter))
uPlot <- get_area_chart(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 203, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Racial Composition of UI Recipients from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("% Native American/Native Alaskan", "% Asian/Pacific Islander", "% Unknown", "% Black", "% White")) +
scale_y_continuous(labels = scales::percent,limits = c(NA, 1))
}
else if (input$viewData == "demographics_sex")
{
metric_filter = c("demographic_sex_prop_men", "demographic_sex_prop_women")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, levels = metric_filter))
uPlot <- get_area_chart(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 203, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Sex Composition of UI Recipients from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("% Women", "% Men")) +
scale_y_continuous(labels = scales::percent,limits = c(NA, 1))
}
else if (input$viewData == "demographics_ethnicity")
{
metric_filter = c("demographic_eth_prop_latinx", "demographic_eth_prop_non_latinx")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, levels = metric_filter))
uPlot <- get_area_chart(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 203, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Latinx Composition of UI Recipients from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("% Latinx", "% Non-Latinx")) +
scale_y_continuous(labels = scales::percent,limits = c(NA, 1))
}
else if (input$viewData == "demographics_age")
{
metric_filter = c("demographic_age_prop_unk", "demographic_age_prop_55_and_older", "demographic_age_prop_45_54", "demographic_age_prop_35_44",
"demographic_age_prop_25_34", "demographic_age_prop_under25")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, levels = metric_filter))
uPlot <- get_area_chart(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 203, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Age Composition of UI Recipients from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("% Unknown", "% 55+", "% 45-54", "% 35-44", "% 25-34", "% Under 25")) +
scale_y_continuous(labels = scales::percent,limits = c(NA, 1))
}
else if (input$viewData == "puaData")
{
metric_filter = c("pua_percent_eligible", "pua_percent_eligible_self_employed", "pua_percent_applicants_self_employed" )
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 902p, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} PUA Eligibility: General and Self Employed from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Overall Eligibility Rate", "Self-Employed Eligibility Rate", "% Self-Employed Applicants")) +
scale_y_continuous(labels = scales::percent)
# adjustment for finding the max height of the graph
metric_filter = c("pua_percent_eligible")
}
else if (input$viewData == "pucClaims")
{
metric_filter = c("puc_weeks")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Weeks Compensated (Thousands)",
caption = "Data courtesy of the USDOL. Report used is ETA 2112, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} PUC Payments: Weeks and Total Amount Compensated from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("PUC $600 Payment")) +
scale_y_continuous(labels = label_number(scale = 1/1000, prefix = "", suffix = "K", big.mark = ","),
sec.axis = sec_axis(trans = ~.*600,
labels = label_number(scale = 1/1000000, prefix = "$", suffix = "M", big.mark = ","),
name = "Total Disbursed (Millions)"))
# adjustment for finding the max height of the graph
metric_filter = c("pua_percent_eligible")
}
else if (input$viewData == "puaClaims")
{
metric_filter = c("pua_initial_applications_total", "pua_eligible_total", "pua_first_payments", "pua_weeks_compensated")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, labels = metric_filter, ordered = TRUE))
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 902p, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} PUA Claims and Payments from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Initial Applications", "Total Eligible", "First Payments", "Weeks Compensated")) +
scale_y_continuous(labels = comma)
}
else if (input$viewData == "recipBreakdown")
{
metric_filter = c("total_week_mov_avg","unemployed_avg")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getLinePlot(df, xlab = "Date", ylab = "",
caption = "Weekly continued claims and Total Unemployed by month.\nBoth numbers are smoothed over 12 month periods. These are the two components of recipiency rate.",
title = glue::glue("{input$state} Recipiency Rate Breakdown from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("total_week_mov_avg","unemployed_avg"),
labels=c("Weekly Continued Claims","Monthy Unemployed (BLS)"))
}
else if (input$viewData == "uirate")
{
metric_filter = c("unemployment_rate_sa")
df <- df %>%
filter(metric %in% metric_filter)
df_us <- unemployed_df %>%
filter(st == "US (avg)",
rptdate >= date_filter_start,
rptdate <= date_filter_end,
metric %in% metric_filter)
uPlot <- getLinePlot(df, xlab = "Date", ylab = "",
caption = "Seasonally adjusted unemployed rate, based on BLS monthly report found here: https://www.bls.gov/web/laus/ststdsadata.txt.",
title = glue::glue("{input$state} Unemployment Rate (SA) from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("perc_unemployed"),
labels=c("Seasonally adjusted unemployment rate")) +
# add the us average line and label
geom_line(data = df_us, size = 1, linetype = "dashed", color = "black") +
annotate("text", x = min(df_us$rptdate), y = df_us %>% filter(rptdate == min(rptdate)) %>% pull(value),
label = "US Avg", vjust = -1, hjust = 0, fontface = "bold")
}
else if (input$viewData == "overvPayments")
{
metric_filter = c("outstanding_proportion")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Outstanding overpayment balance divided by the total benefits paid in all federal and state programs over the last 12 months.\n Data courtesy of the USDOL. Reports used are ETA 227 and 5159, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Overpayment Balance vs Montly UI Payments from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("outstanding_proportion"),
labels=c("Overpayment Balance / Annual UI Payments"))
}
else if (input$viewData == "fraudvNon")
{
metric_filter = c("fraud_num_percent")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 227, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Fraud Overpayments as a Percent of All Overpayments from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("fraud_num_percent"),
labels=c("% Fraud Overpayments")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "TOPS")
{
metric_filter = c("state_tax_recovery", "federal_tax_recovery")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Total Overpayment Recovery",
caption = "Data courtesy of the USDOL. Report used is ETA 227, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Tax Program Overpayment Recovery from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("state_tax_recovery", "federal_tax_recovery"),
labels=c("State Tax Recover", "Federal Tax Recovery")) +
scale_y_continuous(labels = label_number(scale = 1/1000000, prefix = "$", suffix = "M"))
}
## mgh: I can't figure out how to reverse the orders of geoms here. shit.
else if (input$viewData == "recipRate")
{
metric_filter = c("recipiency_annual_fed", "recipiency_annual_reg")
df <- df %>%
filter(metric %in% metric_filter) %>%
mutate(metric = factor(metric, labels = metric_filter, ordered = TRUE))
metric_filter = c("recipiency_annual_total")
uPlot <- getRibbonPlot(df, xlab = "Date", ylab = "Recipiency Rate",
caption = "Recipiency rate calculated by dividing 12 month moving average of unemployment continuing claims divided by 12 month moving average of total unemployed.\nData not seasonally adjusted. \nSource: Continuing claims can be found in ETA report 5159, found here: https://oui.doleta.gov/unemploy/DataDownloads.asp.\nUnemployed numbers courtesy the BLS: https://www.bls.gov/web/laus/ststdnsadata.txt. \nNote that 'regular UI' includes state UI, UFCE, and UCX. Federal programs include EB, and the various EUC programs that have been enacted.",
title = glue::glue("{input$state} Recipiency Rate from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("recipiency_annual_reg","recipiency_annual_fed"),
labels=c("Regular Programs", "Federal Programs"))
}
else if (input$viewData == "overvRecovery")
{
metric_filter = c("outstanding", "recovered")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA 227, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Outstanding State Overpayments vs State $ Recovered from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("outstanding", "recovered"),
labels=c("Outstanding Overpayments", "Overpayments Recovered")) +
scale_y_continuous(labels = label_number(scale = 1/1000000, prefix = "$", suffix = "M"))
}
# Non-Monetary denials. Show a graph of separation denial % and non-separation denial %
else if (input$viewData == "nonMonDen")
{
metric_filter = c("denial_sep_percent_per_determination", "denial_non_percent_per_determination", "denial_rate_overall_per_determination")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of Determinations",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Proportion of Denials for Separation and Non-Separation Reasons\n Per Non-Monetary Decisions {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Separation Denials", "Non-Separation Denials", "Total Denial Rate"))
}
# Non-Monetary denials. Show a graph of separation denial % and non-separation denial %
else if (input$viewData == "nonMonDenInitClaims")
{
metric_filter = c("denial_sep_percent_per_initial_claim", "denial_non_percent_per_initial_claim", "denial_rate_overall_per_initial_claim")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of Initial Claims",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Proportion of Denials for Separation and Non-Separation Reasons\n Per Initial Claims {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels=c("Separation Denials", "Non-Separation Denials", "Total Denial Rate"))
}
else if (input$viewData == "nonMonSep")
{
metric_filter = c("denial_sep_misconduct_percent","denial_sep_vol_percent", "denial_sep_other_percent")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of separation denials",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Proportion of Non-Monetary Separation Denials from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("denial_sep_misconduct_percent","denial_sep_vol_percent", "denial_sep_other_percent"),
labels=c("Misconduct", "Voluntary Quit", "Other"))
}
else if (input$viewData == "nonMonSepRate")
{
metric_filter = c("denial_sep_misconduct_rate_per_determination","denial_sep_vol_rate_per_determination",
"denial_sep_other_rate_per_determination")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of Separation\nDetermination of Each Type",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Non-Monetary Separation Denial Rate Per Determination from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks = metric_filter,
labels=c("Misconduct", "Voluntary Quit", "Other")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "nonMonSepRateInitClaims")
{
metric_filter = c("denial_sep_misconduct_rate_per_initial_claim","denial_sep_vol_rate_per_initial_claim",
"denial_sep_other_rate_per_initial_claim")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of Initial Claims",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Non-Monetary Separation Denial Rate Per Initial Claims from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks = metric_filter,
labels=c("Misconduct", "Voluntary Quit", "Other")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "nonMonNonSep")
{
metric_filter = c("denial_non_aa_percent","denial_non_income_percent", "denial_non_refusework_percent", "denial_non_reporting_percent", "denial_non_referrals_percent", "denial_non_other_percent")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of non-separation denials",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Proportion of Non-Monetary Non-Separation Denials from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks=c("denial_non_aa_percent","denial_non_income_percent", "denial_non_refusework_percent", "denial_non_reporting_percent", "denial_non_referrals_percent", "denial_non_other_percent"),
labels=c("Able and Available", "Disqualifying Income", "Refusal of Suitable Work", "Reporting/Call Ins/Etc...", "Refusal of Referral", "Other"))
}
else if (input$viewData == "nonMonNonSepRate")
{
metric_filter = c("denial_non_aa_rate_per_determination", "denial_non_income_rate_per_determination",
"denial_non_refusework_rate_per_determination", "denial_non_reporting_rate_per_determination",
"denial_non_referrals_rate_per_determination", "denial_non_other_rate_per_determination")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of Determinations Of Each Type",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Denial Rates for Non-Monetary Non-Separation Denials Per Determination from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks = metric_filter,
labels=c("Able and Available", "Disqualifying Income", "Refusal of Suitable Work", "Reporting/Call Ins/Etc...", "Refusal of Referral", "Other")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "nonMonNonSepRateInitClaims")
{
metric_filter = c("denial_non_aa_rate_per_initial_claim", "denial_non_income_rate_per_initial_claim",
"denial_non_refusework_rate_per_initial_claim", "denial_non_reporting_rate_per_initial_claim",
"denial_non_referrals_rate_per_initial_claim", "denial_non_other_rate_per_initial_claim")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Proportion of non-separation denials",
caption = "Data courtesy of the USDOL. Report used is ETA 207, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Denial Rates for Non-Monetary Non-Separation Denials per Initial Claim from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks = metric_filter,
labels=c("Able and Available", "Disqualifying Income", "Refusal of Suitable Work", "Reporting/Call Ins/Etc...", "Refusal of Referral", "Other")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "monetaryDeterminations")
{
metric_filter = c("monetaryDet_mon_eligible_prop")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA ar218, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Monetary Eligibility Rate from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Proportion Monetarily Eligible")) +
scale_y_continuous(labels = scales::percent)
}
else if (input$viewData == "monetaryDeterminations_max_weekly")
{
metric_filter = c("monetaryDet_max_benefit_prop")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Report used is ETA ar218, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Maximum Weekly Benefit Eligibility Rate from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Proportion Eligible for Max Weekly Benefit")) +
scale_y_continuous(labels = scales::percent)
} else if (input$viewData == "monetaryDeterminations_average_weeks") {
metric_filter = c("monetaryDet_avg_weeks_duration")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "Weeks",
caption = "Data courtesy of the USDOL. Report used is ETA ar218, found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Average Weeks Duration of Benefit Received from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Average Weeks Duration"))
} else if (input$viewData == "lowerAuthority") {
metric_filter = c("lower_Within30Days", "lower_Within45Days")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Reports used are ETA 5130, 9050, 9054, and 9055. \nAll can be found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Lower Authority Decision Timeliness from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Decisions Within 30 Days", "Decisions Within 45 Days")) %>%
add_line_with_label(x = min(df$rptdate), y = .6, label = "30-day threshold") %>%
add_line_with_label(x = min(df$rptdate), y = .8, label = "45-day threshold")
} else if(input$viewData == "firstPay") {
metric_filter = c("first_time_payment_Within15Days", "first_time_payment_Within21Days", "first_time_payment_Within35Days")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Reports used are ETA 5130, 9050, 9054, and 9055. \nAll can be found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} First Payment Timeliness from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Payments Within 15 Days", "Payments Within 21 Days", "Payments Within 35 Days")) %>%
add_line_with_label(x = min(df$rptdate), y = .87, label = "15/21-day threshold") %>%
add_line_with_label(x = min(df$rptdate), y = .93, label = "35-day threshold")
} else if(input$viewData == "higherAuthority") {
metric_filter = c("higher_Within45Days", "higher_Within75Days")
df <- df %>%
filter(metric %in% metric_filter)
uPlot <- getPointPlot(df, xlab = "Date", ylab = "",
caption = "Data courtesy of the USDOL. Reports used are ETA 5130, 9050, 9054, and 9055. \nAll can be found at https://oui.doleta.gov/unemploy/DataDownloads.asp.",
title = glue::glue("{input$state} Higher Authority Decision Timeliness from {format.Date(date_filter_start, '%m-%Y')} to {format.Date(date_filter_end, '%m-%Y')}"),
breaks= metric_filter,
labels= c("Decisions Within 45 Days", "Decisions Within 75 Days")) %>%
add_line_with_label(x = min(df$rptdate), y = .4, label = "45-day threshold") %>%
add_line_with_label(x = min(df$rptdate), y = .8, label = "75-day threshold")
}
# constant scaling on the y axis for easier state comparison; scaling on x axis so we can scale to ranges with no recession
if (input$constant_y_axis)
{
# this represents the highest y value of all of the states for this metric
ymax = max(unemployed_df %>%
filter(metric %in% metric_filter,
rptdate > (date_filter_start-10),
rptdate < (date_filter_end+10)) %>%
select(value))
uPlot <- uPlot + coord_cartesian(ylim=c(0, ymax),
xlim=c(as.Date(date_filter_start), as.Date(date_filter_end)))
}
else
{
uPlot <- uPlot + coord_cartesian(xlim=c(as.Date(date_filter_start),as.Date(date_filter_end)))
}
return(uPlot)
})
# render the data table
output$uidata <- renderDataTable({
df <- unemployed_df %>%
filter(st == input$state,
rptdate >= date_filter_start,
rptdate <= date_filter_end)
if (input$viewData == "monthlyUI")
{
col_list = c("total_state_compensated_mov_avg", "total_federal_compensated_mov_avg", "total_state_compensated", "total_federal_compensated", "total_paid_annual_mov_avg")
names_list <- c("State","Report Date", "State UI Payments (Monthly, mov avg)", "Federal UI Payments (Monthly, mov avg)", "State UI Payments (Monthly)", "Federal UI Payments (Monthly)", "Annual UI Payments (mov avg)")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatCurrency(3:7, '$')
}
if (input$viewData %in% c("basicUI_claims", "basicUI_compensated", "basicUI_payment_rate", "basicUI_workshare_continued", "basicUI_workshare_initial"))
{
col_list = c("monthly_initial_claims", "monthly_first_payments", "monthly_weeks_compensated", "monthly_partial_weeks_compensated", "monthly_weeks_claimed",
"monthly_exhaustion", "monthly_first_payments_as_prop_claims", "workshare_initial_claims", "workshare_continued_claims", "workshare_weeks_compensated", "workshare_first_payments")
names_list <- c("State","Report Date", "Initial Claims", "First Payments", "Weeks Compensated", "Partial Weeks Compensated", "Weeks Claimed",
"Number Exhausted", "Initial Payments / Initial Claims", "Workshare Initial Claims", "Workshare Continued Claims", "Workshare Weeks Compensated", "Workshare First Payments")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:8, 10:13), digits = 0) %>%
formatRound(columns=c(9), digits=2)
}
if (input$viewData == "basicWeeklyClaims")
{
col_list = c("weekly_initial_claims", "weekly_continued_claims")
names_list <- c("State","Report Date", "Initial Claims (Weekly)", "Continued Claims (Weekly)")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:4), digits = 0)
}
if (input$viewData == "demographics_race")
{
col_list = c("demographic_race_black", "demographic_race_white", "demographic_race_asian_pacific_islander", "demographic_race_native_american_alaskan", "demographic_race_unk",
"demographic_race_prop_black", "demographic_race_prop_white", "demographic_race_prop_asian_pacific_islander", "demographic_race_prop_native_american_alaskan", "demographic_race_prop_unk")
names_list <- c("State","Report Date", "Black", "White", "Asian/Pacific Islander", "Native American / Native Alaskan", "Unknown",
"% Black", "% White", "% Asian/Pacific Islander", "%Native American / Native Alaskan", "% Unknown")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:7), digits = 0) %>%
formatPercentage(columns = c(8:12))
}
if (input$viewData == "demographics_ethnicity")
{
col_list = c("demographic_eth_latinx", "demographic_eth_non_latinx", "demographic_eth_prop_latinx", "demographic_eth_prop_non_latinx")
names_list <- c("State","Report Date", "Latinx", "Non Latinx", "% Latinx", "% Non-Latinx")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:4), digits = 0) %>%
formatPercentage(columns = c(5:6))
}
if (input$viewData == "demographics_sex")
{
col_list = c("demographic_sex_men", "demographic_sex_women", "demographic_sex_prop_men", "demographic_sex_prop_women")
names_list <- c("State","Report Date", "Men", "Women", "% Men", "% Women")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:4), digits = 0) %>%
formatPercentage(columns = c(5:6))
}
if (input$viewData == "demographics_age")
{
col_list = c("demographic_age_under25", "demographic_age_25_34", "demographic_age_35_44", "demographic_age_45_54", "demographic_age_55_and_older", "demographic_age_unk",
"demographic_age_prop_under25", "demographic_age_prop_25_34", "demographic_age_prop_35_44", "demographic_age_prop_45_54", "demographic_age_prop_55_and_older", "demographic_age_prop_unk")
names_list <- c("State","Report Date", "Under 25", "25-34", "35-44", "45-54", "55+", "Unknown", "% Under 25", "% 25-34", "% 35-44", "% 45-54", "% 55+", "% Unknown")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns = c(3:8), digits = 0) %>%
formatPercentage(columns = c(9:14))
}
if (input$viewData == "puaData")
{
col_list = c("pua_initial_applications_total", "pua_initial_applications_self", "pua_eligible_total", "pua_eligible_self" , "pua_percent_eligible", "pua_percent_eligible_self_employed", "pua_percent_applicants_self_employed")
names_list <- c("State","Report Date", "PUA Initial Applications", "PUA Initial Applications (Self-Employed)", "PUA Eligible", "PUA Eligible (Self-Employed)", "PUA Eligibility Rate (Overall)", "PUA Eligibility Rate (Self-Employed)", "PUA Percent Self-Employed Applicants")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns=c(7:9), digits=2)
}
if (input$viewData == "puaClaims")
{
col_list = c("pua_initial_applications_total", "pua_eligible_total", "pua_first_payments", "pua_weeks_compensated")
names_list <- c("State","Report Date", "PUA Initial Applications", "PUA Eligible", "PUA First Payments", "PUA Weeks Compensated")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatRound(columns=c(3:6), digits=0)
}
if (input$viewData == "pucClaims")
{
col_list = c("puc_payments_total", "puc_weeks")
names_list <- c("State","Report Date", "PUC Total Disbursed", "PUC Weeks Compensated")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatCurrency(3, '$') %>%
formatRound(columns=4, digits = 0)
}
else if (input$viewData == "overvPayments")
{
col_list <- c("outstanding_proportion", "outstanding", "total_paid_annual_mov_avg")
names_list <- c("State","Report Date", "Outstanding balance / Annual UI Payments", "Outstanding Overpayment Balance", "Annual UI Payments")
uiDT <- get_UI_DT_datable(df, col_list, names_list) %>%
formatCurrency(4:5, '$')
}
else if (input$viewData == "fraudvNon")
{
col_list <- c("fraud_num_percent", "regular_fraud_num", "federal_fraud_num", "regular_nonfraud_num", "federal_nonfraud_num")
names_list <- c("State","Report Date", "Fraud as % of Total Overpayments", "Regular UI Fraud", "Federal UI Fraud", "Regular UI Non-Fraud", "Federal UI Non-Fraud")
uiDT <- get_UI_DT_datable(df, col_list, names_list, class = "nowrap stripe") %>%