df <- readRDS(here("./fdata.rds"))
df_covariate <- df %>% select(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status)
df_outcome <- df %>% select(srh, eds, lowcont, epd)
df_all <- df %>% select(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status, srh, eds, lowcont, epd)
df_all <- df_all %>% mutate(Total = 1)
df_covariate %>% tbl_summary(, missing = 'no')
| Characteristic | N = 3,6911 |
|---|---|
| Age | |
| 14-19 | 162 (4.4%) |
| 20-29 | 986 (27%) |
| 30-39 | 994 (27%) |
| 40-49 | 824 (22%) |
| 50-59 | 491 (13%) |
| 60+ | 233 (6.3%) |
| Gender | |
| man | 3,052 (83%) |
| woman | 639 (17%) |
| Income | |
| $0-2,499 | 165 (4.8%) |
| $2,500-9,999 | 447 (13%) |
| $9,999-17,499 | 1,138 (33%) |
| $17,499-29,999 | 1,308 (38%) |
| $30,000 | 383 (11%) |
| Race | |
| Am Indian, Indigenous | 148 (4.0%) |
| Black AA | 137 (3.7%) |
| Other | 1,916 (52%) |
| White | 1,468 (40%) |
| edu_highest | |
| < Primary | 932 (25%) |
| Primary | 1,836 (50%) |
| High school | 832 (23%) |
| College | 90 (2.4%) |
| Read English | |
| Not at all | 1,687 (46%) |
| A little | 908 (25%) |
| Somewhat | 241 (6.5%) |
| Well | 847 (23%) |
| Married | |
| Married/LT | 2,337 (63%) |
| Sep/Divorced | 231 (6.3%) |
| Single | 1,122 (30%) |
| Migrant Type | |
| FTC | 280 (7.6%) |
| Newcomer | 86 (2.3%) |
| Settled | 2,945 (80%) |
| Shuttle | 377 (10%) |
| Documented Status | |
| Citizen | 946 (26%) |
| Green card | 782 (21%) |
| Other work authorization | 56 (1.5%) |
| Unauthorized | 1,884 (51%) |
|
1
n (%)
|
|
df_outcome %>% tbl_summary(, missing = 'no')
| Characteristic | N = 3,6911 |
|---|---|
| Self rated health | |
| Excellent | 747 (20%) |
| Good | 2,115 (57%) |
| Fair | 811 (22%) |
| Poor | 14 (0.4%) |
| Elevated depressive symptoms | 598 (16%) |
| Low control | 536 (16%) |
| Elevated psychological demand | 1,134 (31%) |
|
1
n (%)
|
|
df_all %>%
tbl_summary(
by = srh,
percent = "row",
missing = "no",
include = c(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status, Total),
statistic = list(all_categorical() ~ "{n} ({p}%)")) %>%
add_p() %>%
bold_labels() %>%
modify_header(update = all_stat_cols() ~ "**{level}**") %>% # Remove the Ns from the header row
add_overall(col_label = "**Overall**", last = TRUE) %>%
modify_spanning_header(starts_with("stat_") ~ "**Self-rated health by covariates**")
## 4 observations missing `srh` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `srh` column before passing to `tbl_summary()`.
## There was an error in 'add_p()/add_difference()' for variable 'age', p-value omitted:
## Error in stats::fisher.test(structure(c("30-39", "20-29", "30-39", "20-29", : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'income', p-value omitted:
## Error in stats::fisher.test(structure(c(5L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'race', p-value omitted:
## Error in stats::fisher.test(structure(c("Other", "White", "Other", "White", : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'edu_highest', p-value omitted:
## Error in stats::fisher.test(structure(c(2L, 2L, 2L, 3L, 4L, 3L, 3L, 3L, : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'eng_read', p-value omitted:
## Error in stats::fisher.test(structure(c(2L, 1L, 1L, 4L, 4L, 4L, 4L, 3L, : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'married.LT', p-value omitted:
## Error in stats::fisher.test(structure(c("Married/LT", "Married/LT", "Married/LT", : Bug in fexact3, it[i=4]=0: negative key -1162100415 (kyy=2115)
## There was an error in 'add_p()/add_difference()' for variable 'migrant_2', p-value omitted:
## Error in stats::fisher.test(structure(c("Settled", "Settled", "Settled", : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'doc_status', p-value omitted:
## Error in stats::fisher.test(structure(c("Unauthorized", "Unauthorized", : FEXACT error 501.
## The hash table key cannot be computed because the largest key
## is larger than the largest representable int.
## The algorithm cannot proceed.
## Reduce the workspace, consider using 'simulate.p.value=TRUE' or another algorithm.
## There was an error in 'add_p()/add_difference()' for variable 'Total', p-value omitted:
## Error in stats::chisq.test(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : 'x' and 'y' must have at least 2 levels
| Characteristic | Self-rated health by covariates | p-value2 | ||||
|---|---|---|---|---|---|---|
| Excellent1 | Good1 | Fair1 | Poor1 | Overall1 | ||
| Age | ||||||
| 14-19 | 69 (43%) | 76 (47%) | 17 (10%) | 0 (0%) | 162 (100%) | |
| 20-29 | 249 (25%) | 578 (59%) | 159 (16%) | 0 (0%) | 986 (100%) | |
| 30-39 | 196 (20%) | 598 (60%) | 196 (20%) | 3 (0.3%) | 993 (100%) | |
| 40-49 | 124 (15%) | 473 (58%) | 224 (27%) | 1 (0.1%) | 822 (100%) | |
| 50-59 | 77 (16%) | 248 (51%) | 157 (32%) | 9 (1.8%) | 491 (100%) | |
| 60+ | 31 (13%) | 142 (61%) | 58 (25%) | 1 (0.4%) | 232 (100%) | |
| Gender | 0.2 | |||||
| man | 636 (21%) | 1,742 (57%) | 660 (22%) | 11 (0.4%) | 3,049 (100%) | |
| woman | 111 (17%) | 373 (58%) | 151 (24%) | 3 (0.5%) | 638 (100%) | |
| Income | ||||||
| $0-2,499 | 51 (31%) | 88 (53%) | 25 (15%) | 1 (0.6%) | 165 (100%) | |
| $2,500-9,999 | 86 (19%) | 249 (56%) | 107 (24%) | 3 (0.7%) | 445 (100%) | |
| $9,999-17,499 | 225 (20%) | 639 (56%) | 271 (24%) | 3 (0.3%) | 1,138 (100%) | |
| $17,499-29,999 | 263 (20%) | 789 (60%) | 250 (19%) | 4 (0.3%) | 1,306 (100%) | |
| $30,000 | 89 (23%) | 207 (54%) | 87 (23%) | 0 (0%) | 383 (100%) | |
| Race | ||||||
| Am Indian, Indigenous | 26 (18%) | 92 (62%) | 30 (20%) | 0 (0%) | 148 (100%) | |
| Black AA | 26 (19%) | 73 (53%) | 35 (26%) | 3 (2.2%) | 137 (100%) | |
| Other | 356 (19%) | 1,117 (58%) | 434 (23%) | 7 (0.4%) | 1,914 (100%) | |
| White | 337 (23%) | 820 (56%) | 305 (21%) | 4 (0.3%) | 1,466 (100%) | |
| edu_highest | ||||||
| < Primary | 132 (14%) | 522 (56%) | 273 (29%) | 3 (0.3%) | 930 (100%) | |
| Primary | 336 (18%) | 1,058 (58%) | 432 (24%) | 8 (0.4%) | 1,834 (100%) | |
| High school | 239 (29%) | 491 (59%) | 99 (12%) | 3 (0.4%) | 832 (100%) | |
| College | 39 (43%) | 44 (49%) | 7 (7.8%) | 0 (0%) | 90 (100%) | |
| Read English | ||||||
| Not at all | 275 (16%) | 986 (59%) | 418 (25%) | 5 (0.3%) | 1,684 (100%) | |
| A little | 155 (17%) | 525 (58%) | 226 (25%) | 1 (0.1%) | 907 (100%) | |
| Somewhat | 64 (27%) | 127 (53%) | 49 (20%) | 1 (0.4%) | 241 (100%) | |
| Well | 248 (29%) | 474 (56%) | 118 (14%) | 7 (0.8%) | 847 (100%) | |
| Married | ||||||
| Married/LT | 407 (17%) | 1,351 (58%) | 567 (24%) | 9 (0.4%) | 2,334 (100%) | |
| Sep/Divorced | 34 (15%) | 137 (59%) | 59 (26%) | 1 (0.4%) | 231 (100%) | |
| Single | 306 (27%) | 626 (56%) | 185 (17%) | 4 (0.4%) | 1,121 (100%) | |
| Migrant Type | ||||||
| FTC | 44 (16%) | 153 (55%) | 82 (29%) | 1 (0.4%) | 280 (100%) | |
| Newcomer | 27 (31%) | 49 (57%) | 10 (12%) | 0 (0%) | 86 (100%) | |
| Settled | 608 (21%) | 1,690 (57%) | 632 (21%) | 12 (0.4%) | 2,942 (100%) | |
| Shuttle | 68 (18%) | 220 (59%) | 87 (23%) | 1 (0.3%) | 376 (100%) | |
| Documented Status | ||||||
| Citizen | 262 (28%) | 520 (55%) | 156 (16%) | 8 (0.8%) | 946 (100%) | |
| Green card | 118 (15%) | 443 (57%) | 218 (28%) | 1 (0.1%) | 780 (100%) | |
| Other work authorization | 14 (25%) | 38 (68%) | 3 (5.4%) | 1 (1.8%) | 56 (100%) | |
| Unauthorized | 349 (19%) | 1,102 (59%) | 427 (23%) | 4 (0.2%) | 1,882 (100%) | |
| Total | 747 (20%) | 2,115 (57%) | 811 (22%) | 14 (0.4%) | 3,687 (100%) | |
|
1
n (%)
2
Fisher's exact test
|
||||||
df_all %>%
tbl_summary(
by = eds,
percent = "row",
missing = "no",
include = c(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status, Total),
statistic = list(all_categorical() ~ "{n} ({p}%)")) %>%
add_p() %>%
bold_labels() %>%
modify_header(update = all_stat_cols() ~ "**{level}**") %>% # Remove the Ns from the header row
add_overall(col_label = "**Overall**", last = TRUE) %>%
modify_spanning_header(starts_with("stat_") ~ "**Elevated depressive symptoms by covariates**")
## There was an error in 'add_p()/add_difference()' for variable 'Total', p-value omitted:
## Error in stats::chisq.test(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : 'x' and 'y' must have at least 2 levels
| Characteristic | Elevated depressive symptoms by covariates | p-value2 | ||
|---|---|---|---|---|
| 01 | 11 | Overall1 | ||
| Age | >0.9 | |||
| 14-19 | 140 (86%) | 22 (14%) | 162 (100%) | |
| 20-29 | 821 (83%) | 165 (17%) | 986 (100%) | |
| 30-39 | 833 (84%) | 161 (16%) | 994 (100%) | |
| 40-49 | 688 (83%) | 136 (17%) | 824 (100%) | |
| 50-59 | 411 (84%) | 80 (16%) | 491 (100%) | |
| 60+ | 199 (85%) | 34 (15%) | 233 (100%) | |
| Gender | 0.052 | |||
| man | 2,574 (84%) | 478 (16%) | 3,052 (100%) | |
| woman | 519 (81%) | 120 (19%) | 639 (100%) | |
| Income | 0.034 | |||
| $0-2,499 | 128 (78%) | 37 (22%) | 165 (100%) | |
| $2,500-9,999 | 373 (83%) | 74 (17%) | 447 (100%) | |
| $9,999-17,499 | 951 (84%) | 187 (16%) | 1,138 (100%) | |
| $17,499-29,999 | 1,098 (84%) | 210 (16%) | 1,308 (100%) | |
| $30,000 | 338 (88%) | 45 (12%) | 383 (100%) | |
| Race | <0.001 | |||
| Am Indian, Indigenous | 93 (63%) | 55 (37%) | 148 (100%) | |
| Black AA | 117 (85%) | 20 (15%) | 137 (100%) | |
| Other | 1,674 (87%) | 242 (13%) | 1,916 (100%) | |
| White | 1,192 (81%) | 276 (19%) | 1,468 (100%) | |
| edu_highest | 0.073 | |||
| < Primary | 780 (84%) | 152 (16%) | 932 (100%) | |
| Primary | 1,521 (83%) | 315 (17%) | 1,836 (100%) | |
| High school | 708 (85%) | 124 (15%) | 832 (100%) | |
| College | 83 (92%) | 7 (7.8%) | 90 (100%) | |
| Read English | 0.4 | |||
| Not at all | 1,423 (84%) | 264 (16%) | 1,687 (100%) | |
| A little | 748 (82%) | 160 (18%) | 908 (100%) | |
| Somewhat | 208 (86%) | 33 (14%) | 241 (100%) | |
| Well | 707 (83%) | 140 (17%) | 847 (100%) | |
| Married | 0.013 | |||
| Married/LT | 1,962 (84%) | 375 (16%) | 2,337 (100%) | |
| Sep/Divorced | 178 (77%) | 53 (23%) | 231 (100%) | |
| Single | 952 (85%) | 170 (15%) | 1,122 (100%) | |
| Migrant Type | <0.001 | |||
| FTC | 236 (84%) | 44 (16%) | 280 (100%) | |
| Newcomer | 64 (74%) | 22 (26%) | 86 (100%) | |
| Settled | 2,503 (85%) | 442 (15%) | 2,945 (100%) | |
| Shuttle | 288 (76%) | 89 (24%) | 377 (100%) | |
| Documented Status | 0.4 | |||
| Citizen | 789 (83%) | 157 (17%) | 946 (100%) | |
| Green card | 671 (86%) | 111 (14%) | 782 (100%) | |
| Other work authorization | 48 (86%) | 8 (14%) | 56 (100%) | |
| Unauthorized | 1,566 (83%) | 318 (17%) | 1,884 (100%) | |
| Total | 3,093 (84%) | 598 (16%) | 3,691 (100%) | |
|
1
n (%)
2
Pearson's Chi-squared test
|
||||
df_all %>%
tbl_summary(
by = epd,
percent = "row",
missing = "no",
include = c(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status, Total),
statistic = list(all_categorical() ~ "{n} ({p}%)")) %>%
add_p() %>%
bold_labels() %>%
modify_header(update = all_stat_cols() ~ "**{level}**") %>% # Remove the Ns from the header row
add_overall(col_label = "**Overall**", last = TRUE) %>%
modify_spanning_header(starts_with("stat_") ~ "**Elevated psychological demands by covariates**")
## 17 observations missing `epd` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `epd` column before passing to `tbl_summary()`.
## There was an error in 'add_p()/add_difference()' for variable 'Total', p-value omitted:
## Error in stats::chisq.test(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : 'x' and 'y' must have at least 2 levels
| Characteristic | Elevated psychological demands by covariates | p-value2 | ||
|---|---|---|---|---|
| 01 | 11 | Overall1 | ||
| Age | 0.001 | |||
| 14-19 | 103 (65%) | 55 (35%) | 158 (100%) | |
| 20-29 | 653 (66%) | 332 (34%) | 985 (100%) | |
| 30-39 | 680 (69%) | 310 (31%) | 990 (100%) | |
| 40-49 | 573 (70%) | 246 (30%) | 819 (100%) | |
| 50-59 | 344 (70%) | 145 (30%) | 489 (100%) | |
| 60+ | 187 (81%) | 45 (19%) | 232 (100%) | |
| Gender | 0.2 | |||
| man | 2,115 (70%) | 926 (30%) | 3,041 (100%) | |
| woman | 425 (67%) | 208 (33%) | 633 (100%) | |
| Income | <0.001 | |||
| $0-2,499 | 100 (61%) | 63 (39%) | 163 (100%) | |
| $2,500-9,999 | 297 (67%) | 149 (33%) | 446 (100%) | |
| $9,999-17,499 | 748 (66%) | 384 (34%) | 1,132 (100%) | |
| $17,499-29,999 | 945 (72%) | 361 (28%) | 1,306 (100%) | |
| $30,000 | 280 (73%) | 101 (27%) | 381 (100%) | |
| Race | <0.001 | |||
| Am Indian, Indigenous | 94 (64%) | 53 (36%) | 147 (100%) | |
| Black AA | 95 (69%) | 42 (31%) | 137 (100%) | |
| Other | 1,379 (72%) | 525 (28%) | 1,904 (100%) | |
| White | 956 (65%) | 508 (35%) | 1,464 (100%) | |
| edu_highest | 0.001 | |||
| < Primary | 662 (71%) | 264 (29%) | 926 (100%) | |
| Primary | 1,290 (71%) | 539 (29%) | 1,829 (100%) | |
| High school | 530 (64%) | 298 (36%) | 828 (100%) | |
| College | 57 (63%) | 33 (37%) | 90 (100%) | |
| Read English | <0.001 | |||
| Not at all | 1,175 (70%) | 504 (30%) | 1,679 (100%) | |
| A little | 676 (75%) | 228 (25%) | 904 (100%) | |
| Somewhat | 170 (71%) | 71 (29%) | 241 (100%) | |
| Well | 513 (61%) | 329 (39%) | 842 (100%) | |
| Married | <0.001 | |||
| Married/LT | 1,664 (72%) | 663 (28%) | 2,327 (100%) | |
| Sep/Divorced | 146 (63%) | 85 (37%) | 231 (100%) | |
| Single | 730 (65%) | 385 (35%) | 1,115 (100%) | |
| Migrant Type | <0.001 | |||
| FTC | 156 (56%) | 124 (44%) | 280 (100%) | |
| Newcomer | 57 (66%) | 29 (34%) | 86 (100%) | |
| Settled | 2,051 (70%) | 882 (30%) | 2,933 (100%) | |
| Shuttle | 273 (73%) | 99 (27%) | 372 (100%) | |
| Documented Status | <0.001 | |||
| Citizen | 596 (63%) | 345 (37%) | 941 (100%) | |
| Green card | 606 (78%) | 174 (22%) | 780 (100%) | |
| Other work authorization | 45 (82%) | 10 (18%) | 55 (100%) | |
| Unauthorized | 1,282 (68%) | 593 (32%) | 1,875 (100%) | |
| Total | 2,540 (69%) | 1,134 (31%) | 3,674 (100%) | |
|
1
n (%)
2
Pearson's Chi-squared test
|
||||
df_all %>%
tbl_summary(
by = lowcont,
percent = "row",
missing = "no",
include = c(age, gender, income, race, edu_highest, eng_read, married.LT, migrant_2, doc_status, Total),
statistic = list(all_categorical() ~ "{n} ({p}%)")) %>%
add_p() %>%
bold_labels() %>%
modify_header(update = all_stat_cols() ~ "**{level}**") %>% # Remove the Ns from the header row
add_overall(col_label = "**Overall**", last = TRUE) %>%
modify_spanning_header(starts_with("stat_") ~ "**Low control by covariates**")
## 246 observations missing `lowcont` have been removed. To include these observations, use `forcats::fct_explicit_na()` on `lowcont` column before passing to `tbl_summary()`.
## There was an error in 'add_p()/add_difference()' for variable 'Total', p-value omitted:
## Error in stats::chisq.test(x = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, : 'x' and 'y' must have at least 2 levels
| Characteristic | Low control by covariates | p-value2 | ||
|---|---|---|---|---|
| 01 | 11 | Overall1 | ||
| Age | <0.001 | |||
| 14-19 | 108 (73%) | 40 (27%) | 148 (100%) | |
| 20-29 | 747 (81%) | 174 (19%) | 921 (100%) | |
| 30-39 | 782 (84%) | 149 (16%) | 931 (100%) | |
| 40-49 | 688 (88%) | 90 (12%) | 778 (100%) | |
| 50-59 | 400 (87%) | 58 (13%) | 458 (100%) | |
| 60+ | 184 (88%) | 24 (12%) | 208 (100%) | |
| Gender | 0.14 | |||
| man | 2,421 (85%) | 432 (15%) | 2,853 (100%) | |
| woman | 488 (82%) | 104 (18%) | 592 (100%) | |
| Income | <0.001 | |||
| $0-2,499 | 92 (66%) | 47 (34%) | 139 (100%) | |
| $2,500-9,999 | 318 (76%) | 98 (24%) | 416 (100%) | |
| $9,999-17,499 | 851 (81%) | 198 (19%) | 1,049 (100%) | |
| $17,499-29,999 | 1,137 (91%) | 109 (8.7%) | 1,246 (100%) | |
| $30,000 | 349 (95%) | 20 (5.4%) | 369 (100%) | |
| Race | <0.001 | |||
| Am Indian, Indigenous | 88 (73%) | 32 (27%) | 120 (100%) | |
| Black AA | 102 (76%) | 32 (24%) | 134 (100%) | |
| Other | 1,488 (85%) | 259 (15%) | 1,747 (100%) | |
| White | 1,213 (85%) | 209 (15%) | 1,422 (100%) | |
| edu_highest | <0.001 | |||
| < Primary | 668 (81%) | 161 (19%) | 829 (100%) | |
| Primary | 1,427 (83%) | 289 (17%) | 1,716 (100%) | |
| High school | 731 (90%) | 82 (10%) | 813 (100%) | |
| College | 82 (95%) | 4 (4.7%) | 86 (100%) | |
| Read English | <0.001 | |||
| Not at all | 1,221 (79%) | 326 (21%) | 1,547 (100%) | |
| A little | 716 (86%) | 119 (14%) | 835 (100%) | |
| Somewhat | 210 (91%) | 21 (9.1%) | 231 (100%) | |
| Well | 756 (92%) | 70 (8.5%) | 826 (100%) | |
| Married | <0.001 | |||
| Married/LT | 1,924 (88%) | 268 (12%) | 2,192 (100%) | |
| Sep/Divorced | 170 (81%) | 40 (19%) | 210 (100%) | |
| Single | 815 (78%) | 227 (22%) | 1,042 (100%) | |
| Migrant Type | <0.001 | |||
| FTC | 177 (70%) | 76 (30%) | 253 (100%) | |
| Newcomer | 41 (60%) | 27 (40%) | 68 (100%) | |
| Settled | 2,393 (87%) | 373 (13%) | 2,766 (100%) | |
| Shuttle | 295 (83%) | 60 (17%) | 355 (100%) | |
| Documented Status | <0.001 | |||
| Citizen | 834 (92%) | 77 (8.5%) | 911 (100%) | |
| Green card | 642 (88%) | 89 (12%) | 731 (100%) | |
| Other work authorization | 39 (76%) | 12 (24%) | 51 (100%) | |
| Unauthorized | 1,373 (79%) | 357 (21%) | 1,730 (100%) | |
| Total | 2,909 (84%) | 536 (16%) | 3,445 (100%) | |
|
1
n (%)
2
Pearson's Chi-squared test
|
||||
Color palette is ordered because outcome is ordered
# self rated health and documented status
p1 <- ggplot(data = subset(df_all, !is.na(srh) & !is.na(doc_status)), aes(x=doc_status,
fill=as.factor(srh))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x= "doc. status",
fill = "SRH") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_brewer(palette="Purples", direction=-1)
# self rated health and gender
p2 <- ggplot(data = subset(df_all, !is.na(srh)), aes(x=gender,
fill=as.factor(srh))) +
geom_bar(position="fill", na.rm=T) +
labs(fill = "SRH") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_brewer(palette="Purples", direction=-1)
srh_plot <- ggarrange(p1, p2,
nrow=2,
common.legend = T,
legend="bottom",
align="v")
annotate_figure(srh_plot,
top = text_grob("Self-rated health",
face = "bold", size = 14))
p3 <- ggplot(data = subset(df_all,!is.na(doc_status)), aes(x=doc_status,
fill=as.factor(eds))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Elevated depressive symptoms by documented status",
fill = "EDS") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
p4 <- ggplot(data = subset(df_all,!is.na(gender)), aes(x=gender,
fill=as.factor(eds))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Elevated depressive symptoms",
fill = "EDS") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
p5 <- ggplot(data = subset(df_all,!is.na(doc_status)), aes(x=doc_status,
fill=as.factor(epd))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Elevated psychological demands",
fill = "EPD") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
p6 <- ggplot(data = subset(df_all,!is.na(gender)),
aes(x=gender,
fill=as.factor(epd))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Elevated psychological demands",
fill = "EPD") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
p7 <- ggplot(data = subset(df_all,!is.na(doc_status)), aes(x=doc_status,
fill=as.factor(lowcont))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Low control",
fill = "Low control") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
p8 <- ggplot(data = subset(df_all,!is.na(gender)),
aes(x=gender,
fill=as.factor(lowcont))) +
geom_bar(position="fill", na.rm=T) +
labs(y = "%",
x="",
title = "Low control",
fill = "Low control") +
coord_flip() +
theme_classic() +
theme(legend.position = "bottom", legend.title = element_blank()) +
guides(fill = guide_legend(nrow = 1, label.position = "top", reverse=TRUE)) +
scale_fill_manual(values = c("snow3", "purple3"), labels = c("No", "Yes"))
# data_long <- df_all %>%
# mutate(id = row_number()) %>%
# pivot_longer(
# cols = c("eds", "epd", "lowcont"),
# names_to = "mh_outcomes",
# values_to = "Percent")
#
# ggplot(data = subset(data_long,!is.na(doc_status)),
# aes(x=doc_status,
# y=Percent,
# fill=mh_outcomes)) +
# geom_bar(position="dodge", stat="identity")
mh_plot <- ggarrange(p3, p4, p5, p6, p7, p8,
ncol =2,
common.legend = T,
legend="bottom",
align="v")
mh_plot
## $`1`
##
## $`2`
##
## $`3`
##
## attr(,"class")
## [1] "list" "ggarrange"
# annotate_figure(mh_plot,
# top = text_grob("Mental health outcomes",
# face = "bold", size = 14))