Let’s set up the library packages we might be using for our analysis
library(tidyverse)
library(haven)
library(janitor)
library(descriptio)
#install.packages("weights")
library(weights)
#install.packages("kableExtra")
library(kableExtra)
library(totalcensus)
#install.packages("cdlTools")
library(cdlTools)
Now we read in the data
df_2016 <- read_xpt("./LLCP2016.XPT_")
variable.names(df_2016)
## [1] "_STATE" "FMONTH" "IDATE" "IMONTH" "IDAY" "IYEAR"
## [7] "DISPCODE" "SEQNO" "_PSU" "CTELENM1" "PVTRESD1" "COLGHOUS"
## [13] "STATERES" "CELLFON4" "LADULT" "NUMADULT" "NUMMEN" "NUMWOMEN"
## [19] "CTELNUM1" "CELLFON5" "CADULT" "PVTRESD3" "CCLGHOUS" "CSTATE1"
## [25] "LANDLINE" "HHADULT" "GENHLTH" "PHYSHLTH" "MENTHLTH" "POORHLTH"
## [31] "HLTHPLN1" "PERSDOC2" "MEDCOST" "CHECKUP1" "EXERANY2" "SLEPTIM1"
## [37] "CVDINFR4" "CVDCRHD4" "CVDSTRK3" "ASTHMA3" "ASTHNOW" "CHCSCNCR"
## [43] "CHCOCNCR" "CHCCOPD1" "HAVARTH3" "ADDEPEV2" "CHCKIDNY" "DIABETE3"
## [49] "DIABAGE2" "LASTDEN3" "RMVTETH3" "SEX" "MARITAL" "EDUCA"
## [55] "RENTHOM1" "NUMHHOL2" "NUMPHON2" "CPDEMO1" "VETERAN3" "EMPLOY1"
## [61] "CHILDREN" "INCOME2" "INTERNET" "WEIGHT2" "HEIGHT3" "PREGNANT"
## [67] "DEAF" "BLIND" "DECIDE" "DIFFWALK" "DIFFDRES" "DIFFALON"
## [73] "SMOKE100" "SMOKDAY2" "STOPSMK2" "LASTSMK2" "USENOW3" "ECIGARET"
## [79] "ECIGNOW" "ALCDAY5" "AVEDRNK2" "DRNK3GE5" "MAXDRNKS" "FLUSHOT6"
## [85] "FLSHTMY2" "PNEUVAC3" "TETANUS" "FALL12MN" "FALLINJ2" "SEATBELT"
## [91] "DRNKDRI2" "HADMAM" "HOWLONG" "HADPAP2" "LASTPAP2" "HPVTEST"
## [97] "HPLSTTST" "HADHYST2" "PCPSAAD2" "PCPSADI1" "PCPSARE1" "PSATEST1"
## [103] "PSATIME" "PCPSARS1" "BLDSTOOL" "LSTBLDS3" "HADSIGM3" "HADSGCO1"
## [109] "LASTSIG3" "HIVTST6" "HIVTSTD3" "HIVRISK4" "PDIABTST" "PREDIAB1"
## [115] "INSULIN" "BLDSUGAR" "FEETCHK2" "DOCTDIAB" "CHKHEMO3" "FEETCHK"
## [121] "EYEEXAM" "DIABEYE" "DIABEDU" "PAINACT2" "QLMENTL2" "QLSTRES2"
## [127] "QLHLTH2" "MEDICARE" "HLTHCVR1" "DELAYMED" "DLYOTHER" "NOCOV121"
## [133] "LSTCOVRG" "DRVISITS" "MEDSCOST" "CARERCVD" "MEDBILL1" "MEDADVIC"
## [139] "UNDRSTND" "WRITTEN" "CAREGIV1" "CRGVREL1" "CRGVLNG1" "CRGVHRS1"
## [145] "CRGVPRB2" "CRGVPERS" "CRGVHOUS" "CRGVMST2" "CRGVEXPT" "CIMEMLOS"
## [151] "CDHOUSE" "CDASSIST" "CDHELP" "CDSOCIAL" "CDDISCUS" "SSBSUGR2"
## [157] "SSBFRUT2" "CALRINFO" "MARIJANA" "USEMRJNA" "ASTHMAGE" "ASATTACK"
## [163] "ASERVIST" "ASDRVIST" "ASRCHKUP" "ASACTLIM" "ASYMPTOM" "ASNOSLEP"
## [169] "ASTHMED3" "ASINHALR" "IMFVPLAC" "HPVADVC2" "HPVADSHT" "SHINGLE2"
## [175] "NUMBURN2" "CNCRDIFF" "CNCRAGE" "CNCRTYP1" "CSRVTRT1" "CSRVDOC1"
## [181] "CSRVSUM" "CSRVRTRN" "CSRVINST" "CSRVINSR" "CSRVDEIN" "CSRVCLIN"
## [187] "CSRVPAIN" "CSRVCTL1" "PROFEXAM" "LENGEXAM" "PCPSADE1" "PCDMDECN"
## [193] "SXORIENT" "TRNSGNDR" "RCSGENDR" "RCSRLTN2" "CASTHDX2" "CASTHNO2"
## [199] "EMTSUPRT" "LSATISFY" "QLACTLM2" "USEEQUIP" "QSTVER" "QSTLANG"
## [205] "MSCODE" "_STSTR" "_STRWT" "_RAWRAKE" "_WT2RAKE" "_CHISPNC"
## [211] "_CRACE1" "_CPRACE" "_CLLCPWT" "_DUALUSE" "_DUALCOR" "_LLCPWT2"
## [217] "_LLCPWT" "_RFHLTH" "_PHYS14D" "_MENT14D" "_HCVU651" "_TOTINDA"
## [223] "_MICHD" "_LTASTH1" "_CASTHM1" "_ASTHMS1" "_DRDXAR1" "_EXTETH2"
## [229] "_ALTETH2" "_DENVST2" "_PRACE1" "_MRACE1" "_HISPANC" "_RACE"
## [235] "_RACEG21" "_RACEGR3" "_RACE_G1" "_AGEG5YR" "_AGE65YR" "_AGE80"
## [241] "_AGE_G" "HTIN4" "HTM4" "WTKG3" "_BMI5" "_BMI5CAT"
## [247] "_RFBMI5" "_CHLDCNT" "_EDUCAG" "_INCOMG" "_SMOKER3" "_RFSMOK3"
## [253] "_ECIGSTS" "_CURECIG" "DRNKANY5" "DROCDY3_" "_RFBING5" "_DRNKWEK"
## [259] "_RFDRHV5" "_FLSHOT6" "_PNEUMO2" "_RFSEAT2" "_RFSEAT3" "_DRNKDRV"
## [265] "_RFMAM2Y" "_MAM5021" "_RFPAP33" "_RFPSA21" "_RFBLDS3" "_COL10YR"
## [271] "_HFOB3YR" "_FS5YR" "_FOBTFS" "_CRCREC" "_AIDTST3"
df2_2016<- df_2016 %>% select(`_STATE`,DISPCODE,SEX,GENHLTH,PHYSHLTH,`_PHYS14D`,
MENTHLTH,`_MENT14D`,ADDEPEV2,DIABETE3,HLTHPLN1,
ASTHMA3,`_LTASTH1`,`_MICHD`,CHCSCNCR,CHCOCNCR,
`_HISPANC`,`_RACE`,`_RACEGR3`,`_PSU`,`_STSTR`,
`_STRWT`,`_LLCPWT`,`_LLCPWT2`)
Let’s look at the structure of our data
str(df2_2016)
## tibble [486,303 × 24] (S3: tbl_df/tbl/data.frame)
## $ _STATE : num [1:486303] 1 1 1 1 1 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "STATE FIPS CODE"
## $ DISPCODE: num [1:486303] 1100 1100 1100 1100 1100 1100 1100 1100 1100 1100 ...
## ..- attr(*, "label")= chr "FINAL DISPOSITION"
## $ SEX : num [1:486303] 1 2 2 1 1 2 2 2 2 1 ...
## ..- attr(*, "label")= chr "RESPONDENTS SEX"
## $ GENHLTH : num [1:486303] 1 2 3 3 5 3 3 3 2 2 ...
## ..- attr(*, "label")= chr "GENERAL HEALTH"
## $ PHYSHLTH: num [1:486303] 88 88 88 88 10 88 88 88 88 88 ...
## ..- attr(*, "label")= chr "NUMBER OF DAYS PHYSICAL HEALTH NOT GOOD"
## $ _PHYS14D: num [1:486303] 1 1 1 1 2 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "COMPUTED PHYSICAL HEALTH STATUS"
## $ MENTHLTH: num [1:486303] 88 88 1 88 3 88 88 88 88 88 ...
## ..- attr(*, "label")= chr "NUMBER OF DAYS MENTAL HEALTH NOT GOOD"
## $ _MENT14D: num [1:486303] 1 1 2 1 2 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "COMPUTED MENTAL HEALTH STATUS"
## $ ADDEPEV2: num [1:486303] 2 1 2 2 2 2 2 1 2 2 ...
## ..- attr(*, "label")= chr "EVER TOLD YOU HAD A DEPRESSIVE DISORDER"
## $ DIABETE3: num [1:486303] 3 3 3 1 3 3 3 1 3 3 ...
## ..- attr(*, "label")= chr "(EVER TOLD) YOU HAVE DIABETES"
## $ HLTHPLN1: num [1:486303] 1 1 1 1 1 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "HAVE ANY HEALTH CARE COVERAGE"
## $ ASTHMA3 : num [1:486303] 2 2 2 2 1 2 2 1 2 2 ...
## ..- attr(*, "label")= chr "EVER TOLD HAD ASTHMA"
## $ _LTASTH1: num [1:486303] 1 1 1 1 2 1 1 2 1 1 ...
## ..- attr(*, "label")= chr "LIFETIME ASTHMA CALCULATED VARIABLE"
## $ _MICHD : num [1:486303] 2 2 1 2 2 2 2 2 2 2 ...
## ..- attr(*, "label")= chr "RESPONDENTS THAT HAVE EVER REPORTED HAVI"
## $ CHCSCNCR: num [1:486303] 2 2 1 1 2 2 1 1 2 2 ...
## ..- attr(*, "label")= chr "(EVER TOLD) YOU HAD SKIN CANCER?"
## $ CHCOCNCR: num [1:486303] 2 2 2 2 2 2 2 2 2 2 ...
## ..- attr(*, "label")= chr "(EVER TOLD) YOU HAD ANY OTHER TYPES OF C"
## $ _HISPANC: num [1:486303] 2 2 2 2 2 2 2 2 2 2 ...
## ..- attr(*, "label")= chr "HISPANIC, LATINO/A, OR SPANISH ORIGIN CA"
## $ _RACE : num [1:486303] 1 1 1 1 1 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "COMPUTED RACE-ETHNICITY GROUPING"
## $ _RACEGR3: num [1:486303] 1 1 1 1 1 1 1 1 1 1 ...
## ..- attr(*, "label")= chr "COMPUTED FIVE LEVEL RACE/ETHNICITY CATEG"
## $ _PSU : num [1:486303] 2.02e+09 2.02e+09 2.02e+09 2.02e+09 2.02e+09 ...
## ..- attr(*, "label")= chr "PRIMARY SAMPLING UNIT"
## $ _STSTR : num [1:486303] 11011 11011 11011 11011 11011 ...
## ..- attr(*, "label")= chr "SAMPLE DESIGN STRATIFICATION VARIABLE"
## $ _STRWT : num [1:486303] 37.4 37.4 37.4 37.4 37.4 ...
## ..- attr(*, "label")= chr "STRATUM WEIGHT"
## $ _LLCPWT : num [1:486303] 768 330 291 211 1583 ...
## ..- attr(*, "label")= chr "FINAL WEIGHT: LAND-LINE AND CELL-PHONE D"
## $ _LLCPWT2: num [1:486303] 395 395 197 395 592 ...
## ..- attr(*, "label")= chr "TRUNCATED DESIGN WEIGHT USED IN ADULT CO"
df2_2016 <- clean_names(df2_2016)
names(df2_2016)
## [1] "state" "dispcode" "sex" "genhlth" "physhlth" "phys14d"
## [7] "menthlth" "ment14d" "addepev2" "diabete3" "hlthpln1" "asthma3"
## [13] "ltasth1" "michd" "chcscncr" "chcocncr" "hispanc" "race"
## [19] "racegr3" "psu" "ststr" "strwt" "llcpwt" "llcpwt2"
The results show a tibble (data frame) with 486,303 records and 23 variables of interest. Another point of interest is the variable names, which are a tad messy. We can clean those using the janitor package.
df2_2016 <- clean_names(df2_2016)
names(df2_2016)
## [1] "state" "dispcode" "sex" "genhlth" "physhlth" "phys14d"
## [7] "menthlth" "ment14d" "addepev2" "diabete3" "hlthpln1" "asthma3"
## [13] "ltasth1" "michd" "chcscncr" "chcocncr" "hispanc" "race"
## [19] "racegr3" "psu" "ststr" "strwt" "llcpwt" "llcpwt2"
We will start our analysis performing basic exploratory data analysis for variables of interest and perform cross tabulations.
First let’s look at the distribution of our Race/Ethnicity variables.
#Let's see the distribution of our variable for identifying those that are Hispanic vs those that are not(_HISPANC). _HISPANC is a calculated variable by the CDC base on reponses to the BRFSS survey.
#The variable _HISPANC is coded to where 1 = Hispanic, 2 = Non Hispanic, and 9 = Don't know, refused, or missing. To ease analysis we are going to recode the variable to change the numeric coding to character to ease interpretation.
df2_2016$hisp2 <- NA
df2_2016$hisp2[df2_2016$hispanc == 1] <- "Hispanic"
df2_2016$hisp2[df2_2016$hispanc == 2] <- "Not Hispanic"
df2_2016$hisp2[df2_2016$hispanc == 9] <- NA
hisp <- table(df2_2016$hisp2,useNA = "ifany")
#Display table
hisp %>%
kbl() %>%
kable_paper(full_width = T) %>%
scroll_box(width = "100%", height = "200px")
Var1 | Freq |
---|---|
Hispanic | 39224 |
Not Hispanic | 442452 |
NA | 4627 |
#Barplot with percentages for each group
barplot(hisp * 100 / nrow(df2_2016))
We can do a similar analysis for our Race variable
#Let's see the distribution of our variable for identifying 5 major Race categories based on that provided by the survey). _RACE is a calculated variable by the CDC base on reponses to the BRFSS survey.
#Like the _HISPANC variable, we are going to recode the _RACE variable to ease analysis.
df2_2016$race2 <- NA
df2_2016$race2[df2_2016$race == 1] <- "White"
df2_2016$race2[df2_2016$race == 2] <- "Black"
df2_2016$race2[df2_2016$race == 3] <- "AIAN"
df2_2016$race2[df2_2016$race == 4] <- "Asian"
df2_2016$race2[df2_2016$race == 5] <- "NHPI"
df2_2016$race2[df2_2016$race == 6] <- "Other"
df2_2016$race2[df2_2016$race == 7] <- "Multi"
df2_2016$race2[df2_2016$race == 8] <- "Hisp"
df2_2016$race2[df2_2016$race == 9] <- NA
race <- table(df2_2016$race2,useNA = "ifany")
#Display table
race %>%
kbl() %>%
kable_paper(full_width = T) %>%
scroll_box(width = "100%", height = "200px")
Var1 | Freq |
---|---|
AIAN | 7238 |
Asian | 10492 |
Black | 39555 |
Hisp | 39224 |
Multi | 9442 |
NHPI | 1444 |
Other | 2177 |
White | 368048 |
NA | 8683 |
#Barplot with percentages for each group
barplot(race * 100 / nrow(df2_2016))
Total Population Analysis
#Our analysis will center around the states of New York, Florida, and the territory of Puerto Rico.
selc_state_df <- df2_2016 %>% filter(state == 12 | state == 36 | state == 72)
#Let's recode the State variable to include State Names and Not Fip Codes.
selc_state_df$state2 <- fips(selc_state_df$state,to = 'Abbreviation')
#Let's calculate the total populations for each state.
tot_pop <- selc_state_df %>%
group_by(state) %>%
summarise(tot_pop = sum(llcpwt))
#Calculate crosstabulation by race.
pop_race <- xtabs(llcpwt2 ~ state2 + race2, data = selc_state_df)
kbl(round(pop_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
AIAN | Asian | Black | Hisp | Multi | NHPI | Other | White | |
---|---|---|---|---|---|---|---|---|
FL | 140,011 | 344,037 | 1,841,413 | 3,666,317 | 170,735 | 43,529 | 79,816 | 9,940,170 |
NY | 100,698 | 832,286 | 1,853,225 | 2,774,360 | 227,214 | 64,534 | 9,366 | 9,311,267 |
PR | 0 | 29 | 4,101 | 2,774,966 | 607 | 0 | 5,899 | 13,980 |
General Health Analysis
#Let's reacode GENHLTH to make our analysis simpler.
selc_state_df$genhlth2 <- NA
selc_state_df$genhlth2[selc_state_df$genhlth == 1] <- "Excellent"
selc_state_df$genhlth2[selc_state_df$genhlth == 2] <- "Very Good"
selc_state_df$genhlth2[selc_state_df$genhlth == 3] <- "Good"
selc_state_df$genhlth2[selc_state_df$genhlth == 4] <- "Fair"
selc_state_df$genhlth2[selc_state_df$genhlth == 5] <- "Poor"
selc_state_df$genhlth2[selc_state_df$genhlth == 7] <- NA
selc_state_df$genhlth2[selc_state_df$genhlth == 9] <- NA
#Calculate the crosstabulation for General Health Variable.
genhlth_race <- xtabs(llcpwt2 ~ state2 + race2 + genhlth2, data = selc_state_df)
#Create display table.
kbl(round(genhlth_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | genhlth2 | Freq |
---|---|---|---|
FL | AIAN | Excellent | 35,871 |
NY | AIAN | Excellent | 14,754 |
PR | AIAN | Excellent | 0 |
FL | Asian | Excellent | 86,818 |
NY | Asian | Excellent | 176,539 |
PR | Asian | Excellent | 0 |
FL | Black | Excellent | 389,300 |
NY | Black | Excellent | 307,694 |
PR | Black | Excellent | 636 |
FL | Hisp | Excellent | 749,879 |
NY | Hisp | Excellent | 376,644 |
PR | Hisp | Excellent | 400,294 |
FL | Multi | Excellent | 32,401 |
NY | Multi | Excellent | 42,440 |
PR | Multi | Excellent | 0 |
FL | NHPI | Excellent | 11,224 |
NY | NHPI | Excellent | 10,467 |
PR | NHPI | Excellent | 0 |
FL | Other | Excellent | 19,896 |
NY | Other | Excellent | 2,382 |
PR | Other | Excellent | 1,688 |
FL | White | Excellent | 2,089,903 |
NY | White | Excellent | 2,058,368 |
PR | White | Excellent | 3,695 |
FL | AIAN | Fair | 20,760 |
NY | AIAN | Fair | 22,849 |
PR | AIAN | Fair | 0 |
FL | Asian | Fair | 15,620 |
NY | Asian | Fair | 86,783 |
PR | Asian | Fair | 0 |
FL | Black | Fair | 235,582 |
NY | Black | Fair | 238,970 |
PR | Black | Fair | 1,761 |
FL | Hisp | Fair | 695,774 |
NY | Hisp | Fair | 564,595 |
PR | Hisp | Fair | 902,824 |
FL | Multi | Fair | 19,581 |
NY | Multi | Fair | 37,724 |
PR | Multi | Fair | 0 |
FL | NHPI | Fair | 2,958 |
NY | NHPI | Fair | 9,212 |
PR | NHPI | Fair | 0 |
FL | Other | Fair | 12,775 |
NY | Other | Fair | 2,269 |
PR | Other | Fair | 1,879 |
FL | White | Fair | 1,233,214 |
NY | White | Fair | 958,872 |
PR | White | Fair | 3,291 |
FL | AIAN | Good | 40,635 |
NY | AIAN | Good | 23,601 |
PR | AIAN | Good | 0 |
FL | Asian | Good | 134,313 |
NY | Asian | Good | 306,809 |
PR | Asian | Good | 0 |
FL | Black | Good | 640,969 |
NY | Black | Good | 661,271 |
PR | Black | Good | 1,097 |
FL | Hisp | Good | 1,178,523 |
NY | Hisp | Good | 1,091,523 |
PR | Hisp | Good | 979,148 |
FL | Multi | Good | 45,686 |
NY | Multi | Good | 60,442 |
PR | Multi | Good | 607 |
FL | NHPI | Good | 12,390 |
NY | NHPI | Good | 22,807 |
PR | NHPI | Good | 0 |
FL | Other | Good | 20,096 |
NY | Other | Good | 2,110 |
PR | Other | Good | 1,486 |
FL | White | Good | 2,783,798 |
NY | White | Good | 2,602,654 |
PR | White | Good | 3,566 |
FL | AIAN | Poor | 10,466 |
NY | AIAN | Poor | 12,873 |
PR | AIAN | Poor | 0 |
FL | Asian | Poor | 11,965 |
NY | Asian | Poor | 16,170 |
PR | Asian | Poor | 0 |
FL | Black | Poor | 112,400 |
NY | Black | Poor | 76,677 |
PR | Black | Poor | 0 |
FL | Hisp | Poor | 168,559 |
NY | Hisp | Poor | 191,718 |
PR | Hisp | Poor | 147,510 |
FL | Multi | Poor | 19,819 |
NY | Multi | Poor | 14,788 |
PR | Multi | Poor | 0 |
FL | NHPI | Poor | 1,470 |
NY | NHPI | Poor | 0 |
PR | NHPI | Poor | 0 |
FL | Other | Poor | 1,102 |
NY | Other | Poor | 154 |
PR | Other | Poor | 0 |
FL | White | Poor | 536,580 |
NY | White | Poor | 366,006 |
PR | White | Poor | 58 |
FL | AIAN | Very Good | 29,061 |
NY | AIAN | Very Good | 26,550 |
PR | AIAN | Very Good | 0 |
FL | Asian | Very Good | 95,096 |
NY | Asian | Very Good | 239,198 |
PR | Asian | Very Good | 29 |
FL | Black | Very Good | 458,317 |
NY | Black | Very Good | 558,348 |
PR | Black | Very Good | 607 |
FL | Hisp | Very Good | 861,650 |
NY | Hisp | Very Good | 526,273 |
PR | Hisp | Very Good | 335,013 |
FL | Multi | Very Good | 53,101 |
NY | Multi | Very Good | 71,736 |
PR | Multi | Very Good | 0 |
FL | NHPI | Very Good | 15,487 |
NY | NHPI | Very Good | 20,328 |
PR | NHPI | Very Good | 0 |
FL | Other | Very Good | 25,902 |
NY | Other | Very Good | 2,451 |
PR | Other | Very Good | 846 |
FL | White | Very Good | 3,267,148 |
NY | White | Very Good | 3,294,717 |
PR | White | Very Good | 3,369 |
#write.csv(genhlth_race,"genhlth_race.csv")
Physical Health Analysis
#We can see a barplot of the distribution of given answers to reported days experiencing not good physical health using the _PHYS14D variable. This is a calculated variable that breaks down days reported into 4 groups.
#First we will recode the variable to ease interpretation.
selc_state_df$phys2 <- NA
selc_state_df$phys2[selc_state_df$phys14d==1] <- "Zero Days"
selc_state_df$phys2[selc_state_df$phys14d==2] <- "1-13 Days"
selc_state_df$phys2[selc_state_df$phys14d==3] <- "14+ Days"
#Now we can create a barplot to explore the results for the population included in our states of interest.
phys14d <- table(selc_state_df$phys2,useNA = "ifany")
barplot(phys14d * 100 / nrow(selc_state_df))
physhlth_race <- xtabs(llcpwt2 ~ state2 + race2 + phys2,
data = selc_state_df)
kbl(round(physhlth_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | phys2 | Freq |
---|---|---|---|
FL | AIAN | 1-13 Days | 22,124 |
NY | AIAN | 1-13 Days | 26,568 |
PR | AIAN | 1-13 Days | 0 |
FL | Asian | 1-13 Days | 55,307 |
NY | Asian | 1-13 Days | 180,880 |
PR | Asian | 1-13 Days | 0 |
FL | Black | 1-13 Days | 378,637 |
NY | Black | 1-13 Days | 455,649 |
PR | Black | 1-13 Days | 2,828 |
FL | Hisp | 1-13 Days | 574,292 |
NY | Hisp | 1-13 Days | 767,006 |
PR | Hisp | 1-13 Days | 461,989 |
FL | Multi | 1-13 Days | 40,788 |
NY | Multi | 1-13 Days | 78,747 |
PR | Multi | 1-13 Days | 0 |
FL | NHPI | 1-13 Days | 6,622 |
NY | NHPI | 1-13 Days | 12,338 |
PR | NHPI | 1-13 Days | 0 |
FL | Other | 1-13 Days | 20,170 |
NY | Other | 1-13 Days | 2,098 |
PR | Other | 1-13 Days | 607 |
FL | White | 1-13 Days | 1,973,603 |
NY | White | 1-13 Days | 2,370,251 |
PR | White | 1-13 Days | 1,695 |
FL | AIAN | 14+ Days | 24,060 |
NY | AIAN | 14+ Days | 20,063 |
PR | AIAN | 14+ Days | 0 |
FL | Asian | 14+ Days | 15,750 |
NY | Asian | 14+ Days | 49,668 |
PR | Asian | 14+ Days | 0 |
FL | Black | 14+ Days | 203,767 |
NY | Black | 14+ Days | 199,209 |
PR | Black | 14+ Days | 29 |
FL | Hisp | 14+ Days | 431,381 |
NY | Hisp | 14+ Days | 364,582 |
PR | Hisp | 14+ Days | 471,651 |
FL | Multi | 14+ Days | 34,615 |
NY | Multi | 14+ Days | 38,373 |
PR | Multi | 14+ Days | 0 |
FL | NHPI | 14+ Days | 1,768 |
NY | NHPI | 14+ Days | 4,493 |
PR | NHPI | 14+ Days | 0 |
FL | Other | 14+ Days | 3,631 |
NY | Other | 14+ Days | 2,269 |
PR | Other | 14+ Days | 58 |
FL | White | 14+ Days | 1,394,863 |
NY | White | 14+ Days | 1,063,789 |
PR | White | 14+ Days | 1,815 |
FL | AIAN | Zero Days | 86,835 |
NY | AIAN | Zero Days | 50,983 |
PR | AIAN | Zero Days | 0 |
FL | Asian | Zero Days | 268,614 |
NY | Asian | Zero Days | 575,274 |
PR | Asian | Zero Days | 29 |
FL | Black | Zero Days | 1,188,701 |
NY | Black | Zero Days | 1,117,099 |
PR | Black | Zero Days | 636 |
FL | Hisp | Zero Days | 2,574,314 |
NY | Hisp | Zero Days | 1,519,671 |
PR | Hisp | Zero Days | 1,816,414 |
FL | Multi | Zero Days | 89,297 |
NY | Multi | Zero Days | 106,670 |
PR | Multi | Zero Days | 607 |
FL | NHPI | Zero Days | 33,298 |
NY | NHPI | Zero Days | 44,787 |
PR | NHPI | Zero Days | 0 |
FL | Other | Zero Days | 55,454 |
NY | Other | Zero Days | 4,999 |
PR | Other | Zero Days | 4,627 |
FL | White | Zero Days | 6,363,013 |
NY | White | Zero Days | 5,674,781 |
PR | White | Zero Days | 10,470 |
#write.csv(physhlth_race,"physhlth_race.csv")
Mental Health
#To measure mental health we are basing analysis on teh ADDEPEV2 variable, which measures whether the repondent had ever been told they had a depressive
#disorder.
#Again we can look at the distribution of responses for all individuals in the selected states. First we will again recode the variables for analysis.
selc_state_df$menthlth2 <- NA
selc_state_df$menthlth2[selc_state_df$addepev2==1] <- "Yes"
selc_state_df$menthlth2[selc_state_df$addepev2==2] <- "No"
addepev <- table(selc_state_df$menthlth2,useNA = "ifany")
barplot(addepev * 100 / nrow(selc_state_df))
#Now let's calculate our crosstabs.
menthlth_race <- xtabs(llcpwt2 ~ state2 + race2 + menthlth2,
data = selc_state_df)
#We can visualize our data in table.
kbl(round(menthlth_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | menthlth2 | Freq |
---|---|---|---|
FL | AIAN | No | 112,231 |
NY | AIAN | No | 76,466 |
PR | AIAN | No | 0 |
FL | Asian | No | 330,723 |
NY | Asian | No | 789,200 |
PR | Asian | No | 29 |
FL | Black | No | 1,652,652 |
NY | Black | No | 1,661,323 |
PR | Black | No | 4,071 |
FL | Hisp | No | 3,190,437 |
NY | Hisp | No | 2,425,207 |
PR | Hisp | No | 2,216,524 |
FL | Multi | No | 126,595 |
NY | Multi | No | 182,714 |
PR | Multi | No | 607 |
FL | NHPI | No | 40,790 |
NY | NHPI | No | 61,913 |
PR | NHPI | No | 0 |
FL | Other | No | 76,969 |
NY | Other | No | 9,213 |
PR | Other | No | 5,292 |
FL | White | No | 8,294,173 |
NY | White | No | 8,014,145 |
PR | White | No | 11,486 |
FL | AIAN | Yes | 27,087 |
NY | AIAN | Yes | 24,232 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 12,190 |
NY | Asian | Yes | 33,966 |
PR | Asian | Yes | 0 |
FL | Black | Yes | 185,104 |
NY | Black | Yes | 179,434 |
PR | Black | Yes | 29 |
FL | Hisp | Yes | 450,790 |
NY | Hisp | Yes | 326,062 |
PR | Hisp | Yes | 551,812 |
FL | Multi | Yes | 43,807 |
NY | Multi | Yes | 42,159 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 2,739 |
NY | NHPI | Yes | 2,621 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 2,847 |
NY | Other | Yes | 154 |
PR | Other | Yes | 607 |
FL | White | Yes | 1,609,306 |
NY | White | Yes | 1,256,753 |
PR | White | Yes | 2,494 |
#write.csv(menthlth_race,"menthlth_race.csv")
Asthma Analysis
#We will measure Adults who have ever been told they have asthma. Again we will first recode the variable to ease analysis.
selc_state_df$asthm2 <- NA
selc_state_df$asthm2[selc_state_df$ltasth1==1] <- "No"
selc_state_df$asthm2[selc_state_df$ltasth1==2] <- "Yes"
#Now we can plot individuals that reported ever being told they had asthma or not.
asth <- table(selc_state_df$asthm2,useNA = "ifany")
barplot(asth * 100 / nrow(selc_state_df))
#We can also perform our crosstabulation.
asthma_race <- xtabs(llcpwt2 ~ state2 + race2 + asthm2, data = selc_state_df)
kbl(round(asthma_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | asthm2 | Freq |
---|---|---|---|
FL | AIAN | No | 110,333 |
NY | AIAN | No | 78,621 |
PR | AIAN | No | 0 |
FL | Asian | No | 324,153 |
NY | Asian | No | 748,814 |
PR | Asian | No | 29 |
FL | Black | No | 1,628,826 |
NY | Black | No | 1,555,805 |
PR | Black | No | 1,644 |
FL | Hisp | No | 3,212,649 |
NY | Hisp | No | 2,339,696 |
PR | Hisp | No | 2,291,851 |
FL | Multi | No | 142,994 |
NY | Multi | No | 170,273 |
PR | Multi | No | 607 |
FL | NHPI | No | 40,151 |
NY | NHPI | No | 61,311 |
PR | NHPI | No | 0 |
FL | Other | No | 76,329 |
NY | Other | No | 9,213 |
PR | Other | No | 4,685 |
FL | White | No | 8,855,142 |
NY | White | No | 8,037,881 |
PR | White | No | 11,523 |
FL | AIAN | Yes | 25,291 |
NY | AIAN | Yes | 22,077 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 19,707 |
NY | Asian | Yes | 80,145 |
PR | Asian | Yes | 0 |
FL | Black | Yes | 209,112 |
NY | Black | Yes | 295,020 |
PR | Black | Yes | 2,457 |
FL | Hisp | Yes | 442,069 |
NY | Hisp | Yes | 426,359 |
PR | Hisp | Yes | 481,849 |
FL | Multi | Yes | 27,741 |
NY | Multi | Yes | 56,877 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 3,378 |
NY | NHPI | Yes | 3,223 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 2,044 |
NY | Other | Yes | 154 |
PR | Other | Yes | 1,214 |
FL | White | Yes | 1,055,297 |
NY | White | Yes | 1,257,149 |
PR | White | Yes | 2,457 |
#write.csv(asthma_race,"asthma_race.csv")
Diabetes Analysis
#We will measure Adults who have ever been told they have diabetes. Again we will first recode the variable to ease analysis.
selc_state_df$diab2 <- NA
selc_state_df$diab2[selc_state_df$diabete3==1] <- "Yes"
selc_state_df$diab2[selc_state_df$diabete3==2] <- "Yes, during pregnancy"
selc_state_df$diab2[selc_state_df$diabete3==3] <- "No"
selc_state_df$diab2[selc_state_df$diabete3==4] <- "Pre-diabetes"
#Now we can plot individuals that reported ever being told they had asthma or not.
diab <- table(selc_state_df$diab2,useNA = "ifany")
barplot(diab * 100 / nrow(selc_state_df))
#We can also perform our crosstabulation.
diab_race <- xtabs(llcpwt2 ~ state2 + race2 + diab2, data = selc_state_df)
kbl(round(diab_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | diab2 | Freq |
---|---|---|---|
FL | AIAN | No | 116,863 |
NY | AIAN | No | 74,884 |
PR | AIAN | No | 0 |
FL | Asian | No | 306,880 |
NY | Asian | No | 724,302 |
PR | Asian | No | 0 |
FL | Black | No | 1,463,739 |
NY | Black | No | 1,505,886 |
PR | Black | No | 3,435 |
FL | Hisp | No | 3,157,694 |
NY | Hisp | No | 2,341,778 |
PR | Hisp | No | 2,134,242 |
FL | Multi | No | 147,571 |
NY | Multi | No | 182,719 |
PR | Multi | No | 0 |
FL | NHPI | No | 35,380 |
NY | NHPI | No | 53,608 |
PR | NHPI | No | 0 |
FL | Other | No | 68,481 |
NY | Other | No | 9,213 |
PR | Other | No | 5,292 |
FL | White | No | 8,408,598 |
NY | White | No | 8,219,194 |
PR | White | No | 10,787 |
FL | AIAN | Pre-diabetes | 1,796 |
NY | AIAN | Pre-diabetes | 5,357 |
PR | AIAN | Pre-diabetes | 0 |
FL | Asian | Pre-diabetes | 2,242 |
NY | Asian | Pre-diabetes | 21,126 |
PR | Asian | Pre-diabetes | 0 |
FL | Black | Pre-diabetes | 41,121 |
NY | Black | Pre-diabetes | 43,171 |
PR | Black | Pre-diabetes | 29 |
FL | Hisp | Pre-diabetes | 48,724 |
NY | Hisp | Pre-diabetes | 57,555 |
PR | Hisp | Pre-diabetes | 97,625 |
FL | Multi | Pre-diabetes | 5,026 |
NY | Multi | Pre-diabetes | 7,853 |
PR | Multi | Pre-diabetes | 0 |
FL | NHPI | Pre-diabetes | 0 |
NY | NHPI | Pre-diabetes | 3,936 |
PR | NHPI | Pre-diabetes | 0 |
FL | Other | Pre-diabetes | 1,297 |
NY | Other | Pre-diabetes | 0 |
PR | Other | Pre-diabetes | 0 |
FL | White | Pre-diabetes | 159,714 |
NY | White | Pre-diabetes | 93,161 |
PR | White | Pre-diabetes | 929 |
FL | AIAN | Yes | 19,208 |
NY | AIAN | Yes | 18,967 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 31,760 |
NY | Asian | Yes | 75,394 |
PR | Asian | Yes | 29 |
FL | Black | Yes | 313,031 |
NY | Black | Yes | 284,026 |
PR | Black | Yes | 636 |
FL | Hisp | Yes | 410,034 |
NY | Hisp | Yes | 336,767 |
PR | Hisp | Yes | 527,914 |
FL | Multi | Yes | 16,141 |
NY | Multi | Yes | 32,318 |
PR | Multi | Yes | 607 |
FL | NHPI | Yes | 8,149 |
NY | NHPI | Yes | 5,131 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 9,785 |
NY | Other | Yes | 154 |
PR | Other | Yes | 607 |
FL | White | Yes | 1,243,709 |
NY | White | Yes | 938,184 |
PR | White | Yes | 2,265 |
FL | AIAN | Yes, during pregnancy | 1,795 |
NY | AIAN | Yes, during pregnancy | 671 |
PR | AIAN | Yes, during pregnancy | 0 |
FL | Asian | Yes, during pregnancy | 1,490 |
NY | Asian | Yes, during pregnancy | 8,724 |
PR | Asian | Yes, during pregnancy | 0 |
FL | Black | Yes, during pregnancy | 19,331 |
NY | Black | Yes, during pregnancy | 11,577 |
PR | Black | Yes, during pregnancy | 0 |
FL | Hisp | Yes, during pregnancy | 41,677 |
NY | Hisp | Yes, during pregnancy | 32,067 |
PR | Hisp | Yes, during pregnancy | 11,415 |
FL | Multi | Yes, during pregnancy | 1,943 |
NY | Multi | Yes, during pregnancy | 4,324 |
PR | Multi | Yes, during pregnancy | 0 |
FL | NHPI | Yes, during pregnancy | 0 |
NY | NHPI | Yes, during pregnancy | 1,858 |
PR | NHPI | Yes, during pregnancy | 0 |
FL | Other | Yes, during pregnancy | 228 |
NY | Other | Yes, during pregnancy | 0 |
PR | Other | Yes, during pregnancy | 0 |
FL | White | Yes, during pregnancy | 115,082 |
NY | White | Yes, during pregnancy | 47,641 |
PR | White | Yes, during pregnancy | 0 |
#write.csv(diab_race,"diab_race.csv")
Heart Condition Analysis
#To analyze Heart Conditions we are using the _MICHD variable, which captures whether the respondent have ever reported having coronary heart disease or myocardial infarction.
#Again we will perform some recoding to ease analisis.
selc_state_df$michd2 <- NA
selc_state_df$michd2[selc_state_df$michd==1] <- "Yes"
selc_state_df$michd2[selc_state_df$michd==2] <- "No"
#Now we can plot individuals that reported ever being told they had asthma or not.
michd <- table(selc_state_df$michd2,useNA = "ifany")
barplot(michd * 100 / nrow(selc_state_df))
#Let's perform our crosstabs.
michd_race <- xtabs(llcpwt2 ~ state2 + race2 + michd2, data = selc_state_df)
kbl(round(michd_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | michd2 | Freq |
---|---|---|---|
FL | AIAN | No | 124,405 |
NY | AIAN | No | 83,483 |
PR | AIAN | No | 0 |
FL | Asian | No | 324,399 |
NY | Asian | No | 790,677 |
PR | Asian | No | 29 |
FL | Black | No | 1,693,698 |
NY | Black | No | 1,728,806 |
PR | Black | No | 3,494 |
FL | Hisp | No | 3,451,601 |
NY | Hisp | No | 2,595,800 |
PR | Hisp | No | 2,406,335 |
FL | Multi | No | 155,210 |
NY | Multi | No | 206,329 |
PR | Multi | No | 607 |
FL | NHPI | No | 41,333 |
NY | NHPI | No | 58,580 |
PR | NHPI | No | 0 |
FL | Other | No | 72,647 |
NY | Other | No | 7,097 |
PR | Other | No | 5,899 |
FL | White | No | 8,889,148 |
NY | White | No | 8,545,919 |
PR | White | No | 11,201 |
FL | AIAN | Yes | 14,979 |
NY | AIAN | Yes | 13,233 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 13,755 |
NY | Asian | Yes | 25,376 |
PR | Asian | Yes | 0 |
FL | Black | Yes | 119,136 |
NY | Black | Yes | 102,531 |
PR | Black | Yes | 607 |
FL | Hisp | Yes | 186,214 |
NY | Hisp | Yes | 144,222 |
PR | Hisp | Yes | 360,066 |
FL | Multi | Yes | 15,228 |
NY | Multi | Yes | 17,762 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 2,162 |
NY | NHPI | Yes | 4,096 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 5,156 |
NY | Other | Yes | 0 |
PR | Other | Yes | 0 |
FL | White | Yes | 986,575 |
NY | White | Yes | 713,002 |
PR | White | Yes | 2,779 |
#write.csv(michd_race,"michd_race.csv")
Cancer Analysis
#The BRFSS measures cancer divinf into two variables. One that measures whether the respondent has ever had skin cancer (CHCSCNCR) and another that measures whether the respondent has had any other type of cancer (CHCOCNCR).
#Again we will perform some recoding to ease analisis.
#First let's look at Skin Cancer
selc_state_df$skncncr2 <- NA
selc_state_df$skncncr2[selc_state_df$chcscncr==1] <- "Yes"
selc_state_df$skncncr2[selc_state_df$chcscncr==2] <- "No"
#Now we can plot individuals that reported ever being told they had asthma or not.
skncncr <- table(selc_state_df$skncncr2,useNA = "ifany")
barplot(skncncr * 100 / nrow(selc_state_df))
#Let's perform our crosstabs.
skncancr_race <- xtabs(llcpwt2 ~ state2 + race2 + skncncr2,
data = selc_state_df)
kbl(round(skncancr_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | skncncr2 | Freq |
---|---|---|---|
FL | AIAN | No | 122,335 |
NY | AIAN | No | 97,902 |
PR | AIAN | No | 0 |
FL | Asian | No | 341,416 |
NY | Asian | No | 830,075 |
PR | Asian | No | 29 |
FL | Black | No | 1,828,574 |
NY | Black | No | 1,842,772 |
PR | Black | No | 4,101 |
FL | Hisp | No | 3,565,662 |
NY | Hisp | No | 2,742,833 |
PR | Hisp | No | 2,727,521 |
FL | Multi | No | 160,003 |
NY | Multi | No | 222,853 |
PR | Multi | No | 607 |
FL | NHPI | No | 42,689 |
NY | NHPI | No | 64,293 |
PR | NHPI | No | 0 |
FL | Other | No | 72,694 |
NY | Other | No | 9,366 |
PR | Other | No | 5,899 |
FL | White | No | 8,277,436 |
NY | White | No | 8,560,764 |
PR | White | No | 13,503 |
FL | AIAN | Yes | 16,875 |
NY | AIAN | Yes | 2,796 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 551 |
NY | Asian | Yes | 2,131 |
PR | Asian | Yes | 0 |
FL | Black | Yes | 10,409 |
NY | Black | Yes | 6,700 |
PR | Black | Yes | 0 |
FL | Hisp | Yes | 93,211 |
NY | Hisp | Yes | 23,867 |
PR | Hisp | Yes | 44,534 |
FL | Multi | Yes | 10,702 |
NY | Multi | Yes | 4,362 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 840 |
NY | NHPI | Yes | 241 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 7,097 |
NY | Other | Yes | 0 |
PR | Other | Yes | 0 |
FL | White | Yes | 1,627,186 |
NY | White | Yes | 731,058 |
PR | White | Yes | 477 |
#write.csv(skncancr_race,"skncancr_race.csv")
###############################################################################
#Now let's look at Other Cancer
selc_state_df$othcncr2 <- NA
selc_state_df$othcncr2[selc_state_df$chcocncr==1] <- "Yes"
selc_state_df$othcncr2[selc_state_df$chcocncr==2] <- "No"
#Now we can plot individuals that reported ever being told they had asthma or not.
othcncr <- table(selc_state_df$othcncr2,useNA = "ifany")
barplot(othcncr * 100 / nrow(selc_state_df))
#Let's perform our crosstabs.
othcancr_race <- xtabs(llcpwt2 ~ state2 + race2 + othcncr2,
data = selc_state_df)
kbl(round(othcancr_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria")%>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | othcncr2 | Freq |
---|---|---|---|
FL | AIAN | No | 119,931 |
NY | AIAN | No | 89,124 |
PR | AIAN | No | 0 |
FL | Asian | No | 338,185 |
NY | Asian | No | 820,432 |
PR | Asian | No | 0 |
FL | Black | No | 1,740,008 |
NY | Black | No | 1,727,639 |
PR | Black | No | 4,101 |
FL | Hisp | No | 3,472,117 |
NY | Hisp | No | 2,685,760 |
PR | Hisp | No | 2,589,076 |
FL | Multi | No | 156,560 |
NY | Multi | No | 218,299 |
PR | Multi | No | 607 |
FL | NHPI | No | 40,570 |
NY | NHPI | No | 64,090 |
PR | NHPI | No | 0 |
FL | Other | No | 70,898 |
NY | Other | No | 9,366 |
PR | Other | No | 5,292 |
FL | White | No | 8,834,246 |
NY | White | No | 8,427,400 |
PR | White | No | 13,922 |
FL | AIAN | Yes | 18,885 |
NY | AIAN | Yes | 11,575 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 5,675 |
NY | Asian | Yes | 11,854 |
PR | Asian | Yes | 29 |
FL | Black | Yes | 96,564 |
NY | Black | Yes | 121,088 |
PR | Black | Yes | 0 |
FL | Hisp | Yes | 188,103 |
NY | Hisp | Yes | 83,549 |
PR | Hisp | Yes | 180,382 |
FL | Multi | Yes | 14,146 |
NY | Multi | Yes | 8,915 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 2,959 |
NY | NHPI | Yes | 444 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 8,891 |
NY | Other | Yes | 0 |
PR | Other | Yes | 607 |
FL | White | Yes | 1,077,549 |
NY | White | Yes | 864,722 |
PR | White | Yes | 58 |
#write.csv(othcancr_race,"othcancr_race.csv")
Health Care
#We will measure respondents that have any kind of health care. Again we will first recode the variable to ease analysis.
selc_state_df$hlth2 <- NA
selc_state_df$hlth2[selc_state_df$hlthpln1==1] <- "No"
selc_state_df$hlth2[selc_state_df$hlthpln1==2] <- "Yes"
hlthcr <- table(selc_state_df$hlth2,useNA = "ifany")
barplot(hlthcr * 100 / nrow(selc_state_df))
hlthcr_race <- xtabs(llcpwt2 ~ state2 + race2 + hlth2, data = selc_state_df)
kbl(round(hlthcr_race,0),
format.args = list(big.mark = ","),
align = "c",
escape = F) %>%
kable_classic(full_width = T, html_font = "cambria") %>%
scroll_box(width = "100%", height = "200px")
state2 | race2 | hlth2 | Freq |
---|---|---|---|
FL | AIAN | No | 110,230 |
NY | AIAN | No | 90,644 |
PR | AIAN | No | 0 |
FL | Asian | No | 302,685 |
NY | Asian | No | 755,271 |
PR | Asian | No | 29 |
FL | Black | No | 1,517,289 |
NY | Black | No | 1,668,326 |
PR | Black | No | 4,101 |
FL | Hisp | No | 2,636,895 |
NY | Hisp | No | 2,206,993 |
PR | Hisp | No | 2,619,051 |
FL | Multi | No | 137,981 |
NY | Multi | No | 198,979 |
PR | Multi | No | 607 |
FL | NHPI | No | 31,058 |
NY | NHPI | No | 50,454 |
PR | NHPI | No | 0 |
FL | Other | No | 59,366 |
NY | Other | No | 6,818 |
PR | Other | No | 5,870 |
FL | White | No | 9,023,700 |
NY | White | No | 8,883,704 |
PR | White | No | 13,951 |
FL | AIAN | Yes | 29,178 |
NY | AIAN | Yes | 9,461 |
PR | AIAN | Yes | 0 |
FL | Asian | Yes | 38,678 |
NY | Asian | Yes | 69,968 |
PR | Asian | Yes | 0 |
FL | Black | Yes | 315,626 |
NY | Black | Yes | 168,277 |
PR | Black | Yes | 0 |
FL | Hisp | Yes | 1,010,205 |
NY | Hisp | Yes | 549,898 |
PR | Hisp | Yes | 150,030 |
FL | Multi | Yes | 32,753 |
NY | Multi | Yes | 26,840 |
PR | Multi | Yes | 0 |
FL | NHPI | Yes | 12,250 |
NY | NHPI | Yes | 12,359 |
PR | NHPI | Yes | 0 |
FL | Other | Yes | 20,415 |
NY | Other | Yes | 2,548 |
PR | Other | Yes | 29 |
FL | White | Yes | 859,266 |
NY | White | Yes | 391,650 |
PR | White | Yes | 29 |
#write.csv(hlthcr_race,"hlthcr_race.csv")