-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDescriptiveStatistics.qmd
2093 lines (1576 loc) · 85.5 KB
/
DescriptiveStatistics.qmd
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
# Descriptive Statistics {#sec-descriptivestats}
251630 observations originally in ACS 2021 and 2019 1-year samples.
123,753 observations after removing those not in the labor force and with earned incomes less than or equal to zero.
::: {.callout-warning appearance="simple" icon="false"}
Note: Dropping groups of people using filter() from the sample will change the standard errors of estimates since it changes the sample size. Use the survey() or svy() command to drop subsets of people (like if we wanted to filter age groups). Google what commands to use to drop observations without impacting standard errors.
:::
```{r setup, warning=FALSE, message=FALSE, include=FALSE}
library(scales)
library(reldist)
library(labelled)
library(weights)
library(tigris)
library(ipumsr)
library(srvyr)
library(survey)
library(naniar)
library(gmodels)
library(gtsummary)
library(quarto)
library(huxtable) # for summ() and regression output formatting
# Create the DB connection with the default name expected by PTAXSIM functions
library(jtools)
library(modelsummary)
library(car)
library(tidyverse)
library(pollster)
knitr::opts_chunk$set(warning=FALSE, message=FALSE)
load("./data/WFH.RData")
```
```{r examine-didwfh, eval=FALSE}
# data %>%
# group_by(YEAR, did_wfh) %>%
# dplyr::summarize(weightedcount=sum(PERWT),
# unweightedcount = n()) %>% #weighted
# mutate(pct_weighted = round(weightedcount/sum(weightedcount), digits = 3),
# pct_noweight = round(unweightedcount/sum(unweightedcount), digits = 3))
#valid percent BEFORE final filtering of observations (income greater than zero)
data %>%
filter(YEAR == 2019) %>%
topline(did_wfh_labels, weight = PERWT)
data %>%
filter(YEAR == 2021) %>%
topline(did_wfh_labels, weight = PERWT)
crosstab_3way(joined, YEAR, occ_2dig_labels, did_wfh_labels, weight = PERWT)
```
18.2% of Illinois workers worked at home. 76.3% went to work using some form of transportation, 5.5% of observations were missing values.
- **Valid percent:** 19.2% of observations with responses did WFH and 80.8% of observations with responses did not WFH. **This is the statistic we would use**
- Increased from 5.3% of all workers that worked from home in 2019
## Occupations
Combined into 6 major occupation groups. Broadest categories are made up of multiple 2-digit OCCSOC codes.
```{r}
#| label: A2-Figure1
#| column: page
#| layout-ncol: 2
#| tbl-cap: "Occupation types in Illinois changed very little between 2019 and 2021"
#| fig-cap: "ACS 1 year samples for 2019 and 2021 used for weighted population estimates. Military occupations make up less than 0.5% of the labor force and were removed from the graph. Occupation categories are based on broadest aggregated BLS categories used by the BLS."
table <- svytable(~YEAR+occ_2dig_labels, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(-n)
table
table %>% filter(occ_2dig_labels != "Military") %>% ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels)), y=n, group = YEAR)) +
geom_col(stat = "identity", fill="lightblue") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.02,Prop, "")), accuracy = .1),accuracy = .1L ),position = position_stack(vjust=.5), size=3) +
theme_classic() + theme(legend.position = "bottom", legend.title = element_blank())+
labs(
title ="Proportion of Occupation Types in Illinois",
subtitle = "By Most Aggregated Occupation Groups used by BLS & ACS",
x = "", y = "Estimated Number of Workers")+
scale_y_continuous(labels = scales::comma)+
scale_x_discrete(labels = function(x) str_wrap(x, width=25))+ # makes labels better on axsis
coord_flip()
```
ACS 1 year samples for 2019 and 2021 used for weighted population estimates. Military occupations make up less than 0.5% of the labor force and were removed from the graph. Occupation categories are based on broadest aggregated BLS categories used by the BLS.
```{r}
#| tbl-cap: "Occupations in Illinois by 2-digit OCCSOC code"
### Proportion of All Workers in each Occupation Type ###
table <- svytable(~YEAR+occ_2dig_labels_d, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(-n)
table
```
```{r}
#| label: fig-Figure2-CouldWFH-LaborForce
#| fig-cap: "ACS 1 year samples for 2019 and 2021 used for weighted population estimates. Occupation categories based on first 2 digits of OCCSOC occupation codes. Labels for occupations that make up less than 2% of the workers were not labeled for legibility reasons."
table %>% ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels_d)), y=n, group = YEAR)) +
geom_col(stat = "identity", fill="lightblue") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.02,Prop, "")), accuracy = .1),accuracy = .1L ),position = position_stack(vjust=.5), size=3) +
theme_classic() + theme(legend.position = "bottom", legend.title = element_blank())+
labs(title ="WFH Feasibility by Occupation Type",
#subtitle = "Little change between 2019 and 2021 Occurred",
x = "", y = "Estimated Number of Workers") + scale_y_continuous(labels = scales::comma)+
coord_flip()
```
```{r}
#| layout-ncol: 2
#| column: page
#| fig-location: right
#| fig-cap-location: margin
#| fig-cap: "Percent of Workers working from home within each Broad Occupation type. Same as above but percentages add up differently"
table <- svytable(~YEAR+did_wfh_labels+occ_2dig_labels, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR, occ_2dig_labels)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels, -n)
table
table %>% filter(occ_2dig_labels != "Military" ) %>%
ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels)), y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.05,Prop, "")), accuracy = .1),accuracy = .1L ),position = position_stack(vjust=.5), size=3) +
theme_classic() + theme(legend.position = "bottom", legend.title = element_blank())+
labs(title ="Proportion of Workers in each Occupation Who Did WFH",
# subtitle = "Percentages add to 100% within each occupation",
x = "", y = "Estimated # of People",
caption = "ACS 1 year samples for 2019 and 2021 used for weighted population estimates. Military occupations were excluded from graph due to low occurance of observations.") + scale_y_continuous(labels = scales::comma)+
scale_fill_manual(name = "Reported Work Location", values = c("#a6bddb", "#2b8cbe")) +
coord_flip()
```
```{r }
```
```{r fig-Figure3}
#|tbl-cap: "Proportion of all workers in each occupation category."
#|layout-ncol: 2
#|column: page
table <- svytable(~YEAR+did_wfh_labels+occ_2dig_labels, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels, -n)
table
table %>%
filter(occ_2dig_labels != "Military") %>%
ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels)), y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.02,Prop, "")), accuracy = .1), accuracy = .1L ),
position = position_stack(vjust=.5), size=3) +
theme_classic() +
theme(legend.position = "bottom",
plot.title.position = "plot",
panel.background = element_rect(fill='transparent'), #transparent panel bg
plot.background = element_rect(fill='transparent', color=NA) #transparent plot bg
)+
labs(title ="Proportion of Illinois Workforce Who Worked From Home",
# subtitle = "All workers in labor force with occsoc codes in a year add to 100%",
x = "", y = "Estimated Number of Workers") +#,
# caption = "ACS 1 year samples for 2019 and 2021 used for weighted population estimates,")
scale_y_continuous(labels = scales::comma) +
scale_x_discrete(labels = function(x) str_wrap(x, width=25))+ # makes labels better on axsis
scale_fill_manual(name = "Work Location", values = c("#a6bddb", "#2b8cbe")) + coord_flip()
# ggsave("./paper_figures/Figure3.eps", limitsize = FALSE,width = 8, height = 4, units = "in")
#ggsave("Figure3.pdf", limitsize = FALSE,width = 8, height = 4, units = "in")
# ggsave("./paper_figures/Figure3.png", limitsize = FALSE, width = 8, height = 4, units = "in")
```
```{r A2-Figure4}
#| layout-ncol: 2
#| column: page
### Detailed Occuation Types ##
table <- svytable(~YEAR+did_wfh_labels+occ_2dig_labels_d, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels, -n)
table
table %>%ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels_d)), y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.01,Prop, "")), accuracy = .1),accuracy = .1L ),position = position_stack(vjust=.5), size=3) +
theme_classic() +
theme(legend.position = "bottom",
plot.title.position = "plot",
panel.background = element_rect(fill='transparent'), #transparent panel bg
plot.background = element_rect(fill='transparent', color=NA) #transparent plot bg
)+
labs(title ="Percent of Workers who Worked From Home",
x = "2-Digit Occupation Groups", y = "Estimated Number of Workers") +
scale_y_continuous(labels = scales::comma)+
scale_fill_manual(name = "Work Location", values = c("#a6bddb", "#2b8cbe")) +
coord_flip()
```
ACS 1 year samples for 2019 and 2021 used for weighted population estimates. Graph interpretation: 3.6% of all worker in the labor force in 2021 were in Management occupations and worked from home. 8.3% of all workers were in management and did not work from home. Workers in Management occupations make up 11.9% of the entire workforce.
```{r fig-A2-Figure3}
#| layout-nrow: 1
#| column: page
# Both years, detailed observation types
table <- svytable(~YEAR+CanWorkFromHome+occ_2dig_labels_d, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
arrange(CanWorkFromHome,-n) %>%
mutate(Prop =round(n/sum(n), digits=3))
# table
table %>%
ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels_d)), y=n, fill = CanWorkFromHome, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.01,Prop, "")), accuracy = .1), accuracy= 0.1L ),position = position_stack(vjust=.5), size=3) +
theme_classic() + theme(legend.position = "bottom", legend.title = element_blank())+
labs(title ="Percent of Illinois Workers that Could WFH by Occupation Type",
x = "", y = "Estimated Number of Workers") +
scale_y_continuous(labels = scales::comma)+
scale_fill_manual(values = c( "#117733","#44AA99","#D8D5C5")) +
coord_flip()
```
OCCSOC codes and Teleworkable scores from occupation characteristics. 11.6% of all workers in Illinois had management occupations (6.6 Can WFH + 1.8 No WFH + 3.2 Some WFH in 2021). 6.6% of all workers in Illinois had management occupations and could feasibly WFH. ACS 1 year samples for 2019 and 2021 used for weighted population estimates.
```{r}
#| column: page
table <- svytable(~YEAR+CanWorkFromHome+occ_2dig_labels_d, design = dstrata)
table <- table %>%
as_tibble() %>%
filter(YEAR==2021)%>%
arrange(CanWorkFromHome, -n) %>%
mutate(Prop =round(n/sum(n), digits=3))
table %>%
ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels_d)), y=n,
fill = CanWorkFromHome, group=YEAR)) +
geom_col(position="stack", stat = "identity")+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.01,Prop, "")), accuracy = .1), accuracy= 0.1L ), position = position_stack(vjust=.5), size=3) +
theme_classic() + theme(legend.position = "bottom", legend.title = element_text("WFH Feasibility") )+
labs(title ="Percent of Workers that Could Feasibily Work From Home in 2021",
x = "", y = "Estimated # of Workers",
caption = "Occupation codes (OCCSOC)from the 2021 1-year ACS merged with work from home feasibility scores.") +
scale_y_continuous(labels = scales::comma)+
scale_fill_manual(values = c( "#2b8cbe","#a6bddb","gray80")) +
coord_flip()
```
```{r Figure1}
#| layout-nrow: 1
#| column: page
#| tbl-cap: "Proportion of of all workers in each occupation group who could feasibly work for home."
#| fig-cap: ""
## Proportion of all workers in each occupation cateogory.##
table <- svytable(~YEAR+CanWorkFromHome+occ_2dig_labels, design = dstrata)
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(CanWorkFromHome, -n)
table
Figure1 <- table %>% filter(occ_2dig_labels != "Military") %>%
ggplot(aes(x=fct_rev(fct_inorder(occ_2dig_labels)), y=n, fill = CanWorkFromHome, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.02,Prop, "")), accuracy = .1),accuracy = .1L ),
position = position_stack(vjust=.5), size=2.5) +
theme_classic() +
theme(plot.title = element_text(hjust=0), legend.position = "bottom",
# legend.title = element_text(text = "WFH Feasibility")
# legend.title = element_blank()
)+
labs(title ="WFH Feasibility for Workers in Illinois",
subtitle = "by Broadest Occupation Categories used by BLS",
# subtitle = "All workers in labor force with occsoc codes in a year add to 100%",
x = "", y = "Estimated Number of Workers in Illinois",
# caption = "ACS 1 year samples for 2019 and 2021 used for weighted population estimates"
) +
scale_x_discrete(labels = function(x) str_wrap(x, width=25))+ # makes labels better on axis
scale_y_continuous(labels = scales::comma) +
scale_fill_manual(name = "WFH Feasibility", values = c( "#2b8cbe","#a6bddb", "gray89")) +
coord_flip() # = element_text(hjust = 0, vjust=2.12))
Figure1
ggsave("./paper_figures/Figure1.eps", limitsize = FALSE,width = 8, height = 4, units = "in")#
ggsave("./paper_figures/Figure1.png", limitsize = FALSE, width = 8, height = 4, units = "in")
#ggsave("Figure1.png", limitsize=FALSE, dpi = "retina")
```
## Could WFH vs. did WFH
```{r tbl-CanWFHbyYearanddidWFH}
#| tbl-cap: "Totals add up to total number of workers in Illinois in a year"
#|
table <- svytable(~CanWorkFromHome+YEAR+did_wfh_labels, design = dstrata)
# proportion of each respondant's sex and if they worked from home for each year in sample
table <- table %>%
as_tibble() %>%
group_by(YEAR)%>% # will divide by all workers per year
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels, -n)
table
```
```{r fig-figure7}
#| fig-cap-location: margin
#| fig-cap: "Percentages add up to 100 when adding all workers across WFH Feasibility categories within a year. Work location based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020). ACS 1 year samples for 2019 and 2021 used for weighted population estimates."
## percentages add up to 100 when adding all workers together across WFH Feasibility categories within a year
figure7 <- table %>% ggplot(aes(CanWorkFromHome, y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(as.numeric(ifelse(Prop>0.02,Prop, "")), accuracy = .1), accuracy = .1L ),
position = position_stack(vjust=.5), size=3) +
#scale_fill_manual(values = c("#a6bddb", "#2b8cbe"))+
theme_classic() +
theme(legend.position = "bottom",
legend.title = element_text("Work Location")
) +
labs(title ="Did those who could work from home actually work from home?",
x = "WFH Feasibility based on Respondent's Occupation",
y = "Estimated Number of Workers") +
scale_y_continuous(labels = scales::comma) +
scale_fill_manual(values = c("#a6bddb", "#2b8cbe"))
figure7
ggsave("./paper_figures/Figure7.eps", limitsize = FALSE,width = 8, height = 4, units = "in")
ggsave("./paper_figures/Figure7.png", limitsize = FALSE, width = 7, height = 5, units = "in")
```
```{r tbl-canWFH-byYeardidWFH}
#| tbl-cap: "Proportion of each respondant's sex and if they worked from home for each year in sample"
table <- svytable(~CanWorkFromHome+YEAR+did_wfh_labels, design = dstrata)
# proportion of each respondant's sex and if they worked from home for each year in sample
table <- table %>%
as_tibble() %>%
group_by(YEAR, CanWorkFromHome)%>% # divides by all workers per year within each categor
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels,-n)
table
xtabs(~did_wfh_labels+CanWorkFromHome+YEAR, data = dstrata)
```
```{r fig-Figure7-option2}
#| fig-cap-location: margin
#| fig-cap: "Percentages add up to 100 when adding all workers within each CanWorkFromHome category for each a year. Did work from home based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020). ACS 1 year samples for 2019 and 2021 used for weighted population estimates."
## percentages add up to 100 when adding workers with WFH feasibility category.
table %>% ggplot(aes(fct_inorder(CanWorkFromHome), y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_stack(vjust=.5), size=3) +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank())+
labs(title ="Did those who could work from home actually work from home",
x = "WFH Feasibility", y = "Estimated Number of Workers",
# caption = "Comparison graph that might feel more correct.
# Percentages add up to 100 when adding all workers within each CanWorkFromHome category for each a year.
# Did work from home based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020).
# ACS 1 year samples for 2019 and 2021 used for weighted population estimates."
) + scale_y_continuous(labels = scales::comma)+
scale_fill_manual(values = c("#a6bddb", "#2b8cbe"))
```
```{r}
#| tbl-cap: "Percentages add up to 100 when adding all workers together within each WFH Feasibility Category"
table <- table %>%
as_tibble() %>%
group_by(YEAR, CanWorkFromHome)%>% # divides by all workers per year within each categor
filter(CanWorkFromHome != "Some WFH") %>%
mutate(Prop =round(n/sum(n), digits=3)) %>%
arrange(did_wfh_labels,-n)
table
xtabs(~did_wfh_labels+CanWorkFromHome+YEAR, data = dstrata)
```
```{r fig-Figure7option3}
#| fig-cap: "Percentages add up to 100 when adding all workers within each CanWorkFromHome category for each a year. Did work from home based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020).ACS 1 year samples for 2019 and 2021 used for weighted population estimates."
#| fig-cap-location: margin
## percentages add up to 100 when adding all workers together for a year
figure7_option3 <- table %>% ggplot(aes(fct_inorder(CanWorkFromHome), y=n, fill = did_wfh_labels, group = YEAR)) +
geom_col(stat = "identity", position = "stack") +
facet_wrap(~YEAR)+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_stack(vjust=.5), size=3) +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_text("Reported Work Location"))+
labs(title ="Did those who could work from home actually work from home?",
x = "WFH Feasibility", y = "Estimated Number of Workers",
# caption = "Comparison graph that might feel more correct.
# Percentages add up to 100 when adding all workers within each CanWorkFromHome category for each a year.
# Did work from home based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020).
# ACS 1 year samples for 2019 and 2021 used for weighted population estimates."
) +
scale_y_continuous(labels = scales::comma)+
scale_fill_manual(values = c("#a6bddb", "#2b8cbe"))
#
# table <- svytable(~CanWorkFromHome+YEAR+did_wfh_labels, design = dstrata)
# # proportion of each respondant's sex and if they worked from home for each year in sample
# table <- table %>%
# as_tibble() %>%
# group_by(YEAR, did_wfh_labels)%>% # divides by all workers per year within each categor
# mutate(Prop =round(n/sum(n), digits=3))
## percentages add up to 100 when adding all workers together for a year
## Don't like this version of the graph ###
# table %>% ggplot(aes(did_wfh_labels, y=n, fill = CanWorkFromHome, group = YEAR)) +
# geom_col(stat = "identity", position = "stack") +
# facet_wrap(~YEAR)+
# geom_text(aes(label = scales::percent(Prop)), position = position_stack(vjust=.5), size=3) +
# theme_classic() + theme(legend.position = "bottom", legend.title = element_blank())+
# labs(title ="Did those who COULD work from home actually work from home:", subtitle = "2019 vs 2021",
# x = "", y = "# of People",
# caption = "Comparison graph that might feel more correct.
# Percentages add up to 100 when adding all workers within each did_wfh category for each a year.
# Did work from home based on TRANWORK==80 variable from ACS surveys. Can Work from home based on teleworkable classification in Dingel & Niemen (2020).
# ACS 1 year samples for 2019 and 2021 used for weighted population estimates.") + scale_y_continuous(labels = scales::comma)
figure7_option3
```
> Ideally switch order of categories so that Did WFH is on the bottom of stack. Allows easier visual comparison.
## Income Deciles
```{r create-figure6}
# svyquantile shows the breaks for the quantiles. hypothetically uses weights of observations for calculation of deciles.
# equal number of people should be in each decile after weights are applied
inc_quantiles <- survey::svyquantile(~INCEARN, design=dstrata2019,
quantiles = c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1) , na.rm=TRUE, ci = FALSE )
# $INCEARN for 2019
#[1,] 4 8000 16000 24000 30900 40000 50000 62000 80000 113000 933000
# values not adjusted to 2021 values.
inc_quantiles
inc_quantiles <-survey::svyquantile(~INCEARN, design=dstrata2021,
quantiles = c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1) ,
na.rm=TRUE, ci = FALSE )
inc_quantiles
# $INCEARN
# [1,] 4 7200 16000 25000 34000 42000 52000 67000 85000 120000 949000
breaks2019 <- c(7200, 16000, 25000, 34000, 42000, 52000, 67000, 85000, 120000)
breaks2019adjusted <- c(8478, 16956, 25434, 32853, 42390, 52988, 65705, 84781, 120813)
# from 2021 5 year sample and filtered for just 2019.
# already adjusted for inflation.
# included for comparison and to decide to use 5 year ACS or 2019 and 2021 1 year ACS
breaks2021 <- c(8000, 18000, 26000, 35000, 43000, 54000, 68000, 85000, 120000)
# Code done above when creating variables in beginning chunks.
# joined <- joined %>%
# mutate(incdecile_w = case_when(
# INCEARN < 8000 ~ 1,
# INCEARN >= 8000 & INCEARN < 18000 ~ 2,
# INCEARN >= 18000 & INCEARN < 26000 ~ 3,
# INCEARN >= 26000 & INCEARN < 35000 ~ 4,
# INCEARN >= 35000 & INCEARN < 43000 ~ 5,
# INCEARN >= 43000 & INCEARN < 54000 ~ 6,
# INCEARN >= 54000 & INCEARN < 68000 ~ 7,
# INCEARN >= 68000 & INCEARN < 85000 ~ 8,
# INCEARN >= 85000 & INCEARN < 120000 ~ 9,
# INCEARN >= 120000 ~ 10)
# )
# number of observations in each decile after weights used for creating the income deciles
#table(joined$incdecile_w)
# no major differnce between years in who COULD work from home based on teleworkable codes. Makes sense.
# ggplot(joined, aes(teleworkable, weight = PERWT)) +
# geom_histogram()+facet_wrap(~YEAR)
table <- svytable(~YEAR+incdecile_w+did_wfh_labels, design = dstrata) # proportion of each respondants sex in sample
table <- table %>%
as_tibble() %>%
group_by(YEAR,incdecile_w)%>%
mutate(Prop=round(n/sum(n), digits=3)) %>%
filter(did_wfh_labels == "Did WFH")
table # has proportions calculated out of TOTAl for both years
```
```{r fig-figure6}
table %>%
ggplot(aes(factor(incdecile_w, levels = c(1,2,3,4,5,6,7,8,9,10), labels = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")),
y=Prop, fill = YEAR, group = factor(YEAR, levels = "2021","2019"))) +
geom_col(stat="identity", position = "dodge")+
#geom_col(stat = "identity", position = "stack") + # scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# facet_wrap(~YEAR)+
coord_flip()+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_dodge(width = 0.8), hjust = 1.1,
size = 4) +
labs(title ="Working From Home by Earned Income Deciles",
subtitle = "2019 vs 2021",
# caption = "ACS 1 year samples for 2019 and 2021. Working from home based on TRANWORK question on commuting.
# All workers in the labor force, all ages included.
# Income based on INCEARN for total earned income of survey respondents.",
x= "Income Deciles",
y = "Percent of earners working from home") +
theme(legend.position = "none", legend.title = element_blank())+
theme_classic()+
scale_fill_manual(values = c("#a6bddb", "#2b8cbe")) +
scale_y_continuous(labels = scales::percent)
ggsave("./paper_figures/Figure6.eps", limitsize = FALSE,width = 8, height = 4, units = "in")
#ggsave("Figure6.pdf", limitsize = FALSE,width = 8, height = 4, units = "in")
ggsave("./paper_figures/Figure6.png", limitsize = FALSE, width = 8, height = 4, units = "in")
```
```{r eval=FALSE, include=FALSE}
table18up<-subset(dstrata,AGE>17)
table18up <- svytable(~YEAR+incdecile_w+did_wfh_labels, design = table18up) # proportion of each respondants sex in sample
table18up <- table18up %>%
as_tibble() %>%
group_by(YEAR,incdecile_w)%>%
mutate(Prop=round(n/sum(n), digits=3)) %>%
filter(did_wfh_labels == "Did WFH")
table18up # has proportions calculated out of TOTAl for both years
table18up %>%
ggplot(aes(factor(incdecile_w, levels = c(1,2,3,4,5,6,7,8,9,10), labels = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")),
y=Prop, fill = YEAR, group = factor(YEAR, levels = "2021","2019"))) +
geom_col(stat="identity", position = "dodge")+
#geom_col(stat = "identity", position = "stack") + # scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# facet_wrap(~YEAR)+
coord_flip()+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_dodge(width = 0.8), hjust = 1.1,
size = 4) +
labs(title ="Ages 18+: Percent of each income decile that worked from home",
subtitle = "2019 vs 2021",
caption = "ACS 1 year samples for 2019 and 2021. Working from home based on TRANWORK question on commuting.
All workers in the labor force, all ages included.
Income based on INCEARN for total earned income of survey respondents.",
x= "Income Deciles",
y = "Percent of workers working from home") +
theme(legend.position = "bottom", legend.title = element_blank())+
theme_classic()+
scale_y_continuous(labels = scales::percent)
table25up<-subset(dstrata, AGE>24)
table25up <- svytable(~YEAR+incdecile_w+did_wfh_labels, design = table25up) # proportion of each respondants sex in sample
table25up <- table25up %>%
as_tibble() %>%
group_by(YEAR,incdecile_w)%>%
mutate(Prop=round(n/sum(n), digits=3)) %>%
filter(did_wfh_labels == "Did WFH")
table25up # has proportions calculated out of TOTAl for both years
table25up %>%
ggplot(aes(factor(incdecile_w, levels = c(1,2,3,4,5,6,7,8,9,10), labels = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")),
y=Prop, fill = YEAR, group = factor(YEAR, levels = "2021","2019"))) +
geom_col(stat="identity", position = "dodge")+
#geom_col(stat = "identity", position = "stack") + # scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# facet_wrap(~YEAR)+
coord_flip()+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_dodge(width = 0.8), hjust = 1.1,
size = 4) +
labs(title ="Ages 25+: Percent of each income decile that worked from home",
subtitle = "2019 vs 2021",
caption = "ACS 1 year samples for 2019 and 2021. Working from home based on TRANWORK question on commuting.
All workers in the labor force, all ages included.
Income based on INCEARN for total earned income of survey respondents.",
x= "Income Deciles",
y = "Percent of workers working from home") +
theme(legend.position = "bottom", legend.title = element_blank())+
theme_classic()+
scale_y_continuous(labels = scales::percent)
```
```{r svy-tables}
#| include: FALSE
# joined %>% filter(YEAR == 2019) %>%
# tbl_summary(include = c(-OCCSOC, -PUMA),
# statistic = list(all_continuous() ~"{mean} ({sd})"))
# weights_2019table <- full_tidy_2019 %>%
# tbl_svysummary(include = c(INCEARN, INCWAGE, TRANWORK, EMPSTAT, LABFORCE, SEX, AGE, RACE, CLASSWKR))
# design2019 %>%
# tbl_svysummary(include = c(-OCCSOC, -PUMA))
#
# design2021 %>%
# tbl_svysummary(include = c(-OCCSOC, -PUMA))
#
# shows the breaks for the quantiles. hypothetically uses weights of observations for calculation of deciles.
# equal number of people should be in each decile after weights.
# incomebywfh <- dstrata2021 %>%
# mutate(INCEARN = as.numeric(INCEARN) )%>%
# svyby(formula = ~INCEARN, by = ~did_wfh_labels,# design = dstrata2021,
# FUN = svyquantile,
# na.rm=TRUE,
# keep.names = FALSE,
# quantiles = c(0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9) )
#
# incomebywfh
## ^ Income deciles by wfh status.
# The poorest 10% of WFH workers are earning almost more than the the bottom 20% of earners who did not WFH
```
> who did work from home in lower income brackets???
- 399011 in Service Occupations had 148 observations, 311122 had 86.
- Vast Majority of those that did work form home in the bottom 10% of earners had management, business, sales, or office jobs. (specifically 399011, 253041,436014)
- **outliers**: occupation 537062, 533030, 537065 in production and transportation, 399011 in service occupations which usually need to be in person.
- 399011 (2nd and 3rd decile), 311122 (2nd and 3rd decile)
```{r}
joined %>% filter(did_wfh==1 & incdecile_w < 4) %>% group_by(incdecile_w, occ_2digits, occ_2dig_labels, OCCSOC) %>% summarize(obs = n()) %>% arrange(incdecile_w,-obs)
```
> percent includes both years for combined strata.
```{r graphing-inc-deciles-notweighted, include=FALSE, eval=FALSE}
#min= -8000, max=949000 for INCEARN
#code from above
dstrata %>% group_by(YEAR) %>% summarize(count = n())
dstrata %>%
as_data_frame() %>%
dplyr::group_by(YEAR)%>%
# mutate(yrcount=)
filter(did_wfh==1) %>%
ggplot(aes(x=decile,
y = (..count..)/(sum(..count..))*10,
fill=factor(YEAR)
)) +
geom_bar(position=position_dodge())+
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")) +
# scale_y_discrete(limits = c("2019", "2021")) +
#scale_y_continuous(labels=percent) +
labs(x="",y="",
title = "Using dstrata dataframe: % of workers who worked at home by income decile in 2019 and 2021",
subtitle = "PERCENT IS CALCULATED FROM TOTAL OBS FOR BOTH YEARS: FIX")+
coord_flip()
# dstrata2019 %>%
# as_data_frame() %>%
# filter(did_wfh_labels != "NA") %>%
# ggplot(aes(x=decile,
# y = (..count..)/(sum(..count..))*10,
# fill=did_wfh_labels
# )) +
# geom_bar(position="fill")+
# theme(legend.position = "bottom", legend.title = element_blank()) +
# scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")) +
# labs(x="",y="",
# title = "2019 Data: Who DID work from home?",
# subtitle = "Percent of WFH workers by income decile")+
# coord_flip()
dstrata2021 %>%
as_data_frame() %>%
filter(did_wfh_labels != "NA") %>%
ggplot(aes(x=decile,
y = (..count..)/(sum(..count..))*10,
fill=did_wfh_labels
)) +
geom_bar(position="fill")+
theme(legend.position = "bottom", legend.title = element_blank()) +
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")) +
labs(x="",y="",
title = "2021: Who DID work from home?",
subtitle = "Percent of WFH workers by income decile")+
coord_flip()
dstrata %>%
as_data_frame() %>%
filter(YEAR == 2019) %>%
count(did_wfh, decile) %>%
mutate(pct = round(n/sum(n)*1000, 1))%>%
filter(did_wfh == 1)%>%
#filter(did_wfh == "Can WFH") %>%
#group_by(decile)%>%
#summarize(count2 = n()) %>%
ungroup()%>%
ggplot(aes(x=decile,
# group = YEAR,
y = pct,
)) +
geom_col() +
# geom_col(aes(fill=YEAR)) +
coord_flip()+
theme(legend.position = "bottom") +
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
geom_text(aes(label=paste0(pct,"%")), hjust=1.3)+
labs(x="",y="% Worked at Home", title = "Individuals with higher income were more able to work from home",
subtitle = "2019 ACS 1-year Sample with incorrectly weighted deciles",
caption = "Did work from home is based on ACS variable TRANWORK.
Delete this graph eventually. Keeping it for code comparison for now.")+
theme_minimal()+
theme(legend.position = "none")
# CanWFH2019 <- dstrata2019 %>%
# as_data_frame() %>%
# # mutate(total = n()) %>%
# filter(CanWorkFromHome != "Check Me") %>%
# ggplot(aes(x=decile,
# y = (..count..)/sum(..count..)*10,
# fill = CanWorkFromHome)) +
# geom_bar( position = "dodge") +
# #coord_flip()+
# theme(legend.position = "bottom", legend.title = element_blank()) +
#
# scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# scale_y_continuous(labels=scales::percent) +
# labs(x="",y="", title = "2019 Data: Who Could work from home?", subtitle = "Based on Job Characteristics")
#
# CanWFH2019
#
#
#
# CanWFH2021 <- dstrata2021 %>%
# as_data_frame() %>%
# # mutate(total = n()) %>%
# filter(CanWorkFromHome != "Check Me") %>%
# ggplot(aes(x=decile,
# y = (..count..)/sum(..count..)*10,
# fill = CanWorkFromHome)) +
# geom_bar( position = "dodge") +
# #coord_flip()+
# theme(legend.position = "bottom", legend.title = element_blank()) +
#
# scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# scale_y_continuous(labels=scales::percent) +
# labs(x="",y="", title = "2021 Data: Who Could work from home?", subtitle = "Based on Job Characteristics")
#
# CanWFH2021
# dstrata2019 %>%
# as_data_frame() %>%
# # mutate(total = n()) %>%
# filter(CanWorkFromHome != "Check Me") %>%
# ggplot(aes(x=decile,
# y = (..count..)/sum(..count..)*10,
# fill = YEAR)) +
# geom_bar(aes(fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))),position = "stack") +
# #coord_flip()+
# theme(legend.position = "bottom", legend.title = element_blank()) +
#
# scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# scale_y_continuous(labels=scales::percent) +
# labs(x="",y="", title = "2019 Data")+coord_flip()
# dstrata2021 %>%
# as_data_frame() %>%
# # mutate(total = n()) %>%
# filter(CanWorkFromHome != "Check Me") %>%
# ggplot(aes(x=decile,
# y = (..count..)/sum(..count..)*10,
# fill = YEAR)) +
# geom_bar(aes(fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))),position = "stack") +
# #coord_flip()+
# theme(legend.position = "bottom", legend.title = element_blank()) +
#
# scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
# scale_y_continuous(labels=scales::percent) +
# labs(x="",y="", title = "2021 Data")+
# coord_flip()
```
```{r include=FALSE, eval=FALSE}
dstrata2019 %>%
as_data_frame() %>%
filter(CanWorkFromHome != "Check Me") %>%
count(decile, CanWorkFromHome) %>%
mutate(pct = round(n/sum(n/10), 3)*100)%>%
ggplot(aes(x=decile, y = n,
fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))
)) +
geom_bar( stat = "identity") +
coord_flip()+
geom_text(aes(label=paste0(pct, "%")),
position = position_stack(vjust=0.5), size=2.5)+
theme(legend.position = "bottom", legend.title = element_blank()) +
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
guides(fill = guide_legend(reverse = TRUE))+
#scale_y_continuous(labels=scales::percent) +
labs(x="Earned Income Deciles", y="# Survey Responses",
title = "Ability to work from home based on occupational characteristics",
subtitle = "HAS COUNTS on x axis: FIX THAT",
caption = "Occupation data from ACS 1-year 2019 sample.")
dstrata2021 %>%
as_data_frame() %>%
filter(CanWorkFromHome != "Check Me") %>%
ggplot(aes(x=decile,
fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))
)) +
geom_bar( position = "fill") +
coord_flip()+
geom_text( aes(label=paste0(signif(..count.. / tapply(..count.., ..x.., sum)[as.character(..x..)], digits=3)*100,"%")),
stat="count", position = position_fill(vjust=0.5), size=3) +
theme(legend.position = "bottom", legend.title = element_blank()) +
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
guides(fill = guide_legend(reverse = TRUE))+
#scale_y_continuous(labels=scales::percent) +
labs(x="Earned Income Deciles", y="% Survey Responses",
title = "Ability to work from home based on occupational characteristics",
caption = "Occupation data from ACS 1-year 2021 sample.")
dstrata2021 %>%
as_data_frame() %>%
filter(CanWorkFromHome != "Check Me") %>%
ggplot(aes(x=decile,
fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))
)) +
geom_bar(aes(fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH"))), position = "fill") +
coord_flip()+
geom_text( aes(label=paste0(signif(..count.. / tapply(..count.., ..x.., sum)[as.character(..x..)], digits=3)*100,"%")),
stat="count", position = position_fill(vjust=0.5), size=3) +
theme(legend.position = "bottom", legend.title = element_blank()) +
scale_x_discrete(limits = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%"))+
guides(fill = guide_legend(reverse = TRUE))+
#scale_y_continuous(labels=scales::percent) +
labs(x="Earned Income Deciles", y="% Survey Responses",
title = "Ability to work from home based on occupational characteristics",
caption = "Occupation data from ACS 1-year 2021 sample.")
```
```{r can-WFH-graphs}
#| code-fold: true
table <- svytable(~YEAR+incdecile_w+CanWorkFromHome, design = dstrata) # proportion of each respondants sex in sample
table <- table %>%
as_tibble() %>%
group_by(YEAR, incdecile_w)%>%
mutate(Prop=round(n/sum(n), digits=3)) %>%
mutate(CanWorkFromHome = factor(CanWorkFromHome, levels = c('No WFH', 'Some WFH', 'Can WFH')))
table
table[rev(order(table$CanWorkFromHome)),]%>%
ggplot(aes(factor(incdecile_w, levels = c(1,2,3,4,5,6,7,8,9,10),
labels = c("Bottom 10%", "20%", "30%", "40%", "50%", "60%", "70%", "80%", "90%", "Top 10%")),
y=Prop,
# fill = CanWorkFromHome,
fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH")),
group = factor(YEAR, levels = "2021","2019"))) +
geom_col(aes(fill = factor(CanWorkFromHome, levels = c("No WFH", "Some WFH", "Can WFH")),stat="identity", position = "stack"))+
coord_flip()+
geom_text(aes(label = scales::percent(Prop, accuracy = 0.1L)), position = position_fill(vjust =.5), size = 2) +
guides(fill = guide_legend(reverse = TRUE))+
labs(title ="Percent of each income decile that could potentially work from home",
subtitle = "2019 vs 2021",
caption = " Based on occupation codes from ACS 1 year samples for 2019 and 2021. Teleworkable coding based on Dingel & Neimen 2020.
All workers in the labor force, all ages included.
Income based on INCEARN for total earned income of survey respondents.",
x= "Income Deciles",
y = "Percent of workers that can work from home based on occupation characteristics") + theme_classic()+
theme(legend.position = "bottom", legend.title = element_blank())+
scale_y_continuous(labels = scales::percent) + facet_wrap(~YEAR)
```
```{r agegroup-comparison, eval=FALSE, include=FALSE}
# Bottom 10% of earners change the most depending on the age groups incuded in sample.
table <- svytable(~YEAR+incdecile_w+CanWorkFromHome, design = dstrata) # proportion of each respondants sex in sample
table <- table %>%
as_tibble() %>%