带有NA值的吊图
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了带有NA值的吊图相关的知识,希望对你有一定的参考价值。
我一直在使用此代码
ggplot(Oak, aes(x = age, fill = factor(subject_talk))) +
geom_bar(aes(y = (..count..)/sum(..count..)),position = "stack") +
xlim(18,29) +
scale_fill_manual(breaks=c("0","1"), values = scales::hue_pal()(2))
创建看起来像这样的图
最近,某些图最终以浮动的形式出现在NA值应处于的位置,
我不想要的。
这里是2的代码
ggplot(Oak, aes(x = age, fill = factor(highcho))) +
geom_bar(aes(y = (..count..)/sum(..count..)),position = "stack") +
xlim(18,29) +
scale_fill_manual(breaks=c("0","1"), values = scales::hue_pal()(2))
输出太长,无法设置为代码,否则无法发布。
dput(head(Oak,20))
structure(list(studyid = structure(c(1002, 1002, 1002, 1002,
1002, 1004, 1004, 1004, 1004, 1004, 1005, 1005, 1005, 1005, 1005,
1006, 1006, 1006, 1006, 1006), label = "Subject Study ID", format.stata = "%12.0g"),
post_flu = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 0, 0, 0, 0, 0), label = "Receipt of Flu Vaccine - Encounter Survey", format.stata = "%10.0g"),
post_bmi = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "BMI Test Received - Encounter Survey", format.stata = "%9.0g"),
post_bp = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Blood Pressure Test Received - Encounter Survey", format.stata = "%9.0g"),
post_dia = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Diabetes Test Received - Encounter Survey", format.stata = "%9.0g"),
post_cho = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Cholesterol Test Received - Encounter Survey", format.stata = "%9.0g"),
post_flu_sl = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, NA, NA, NA, NA, NA), label = "Flu Shot Received (Subsidy Received) - Encounter Survey", format.stata = "%9.0g"),
post_flu_nosl = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 0, 0, 0, 0, 0), label = "Flu Shot Received (No Subsidy Received) - Encounter Survey", format.stata = "%9.0g"),
post_shr_invasive = structure(c(1, 1, 1, 1, 1, 0.666666686534882,
0.666666686534882, 0.666666686534882, 0.666666686534882,
0.666666686534882, 0.333333343267441, 0.333333343267441,
0.333333343267441, 0.333333343267441, 0.333333343267441,
0, 0, 0, 0, 0), label = "Post Take-Up as Share of Invasive Services", format.stata = "%9.0g"),
post_share4 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Post Take-Up as Share of Four Services", format.stata = "%9.0g"),
pre_bmi = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Weight and Height Selected - CTO Patient Survey", format.stata = "%8.0g"),
pre_bp = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Blood Pressure Selected - CTO Patient Survey", format.stata = "%8.0g"),
pre_dia = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Diabetes Selected - CTO Patient Survey", format.stata = "%8.0g"),
pre_cho = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Cholesterol Selected - CTO Patient Survey", format.stata = "%8.0g"),
pre_flu = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Flu Shot Selected - CTO Patient Survey", format.stata = "%8.0g", labels = c(No = 0,
Yes = 1, Unsure = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), pre_flu_sl = structure(c(1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, NA, NA, NA, NA, NA), label = "Flu Shot Selected (Subsidy Received) - CTO Survey", format.stata = "%9.0g"),
pre_flu_nosl = structure(c(NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, 0, 0, 0, 0, 0), label = "Flu Shot Selected (No Subsidy Received) - CTO Survey", format.stata = "%9.0g"),
pre_shr_invasive = structure(c(0.333333343267441, 0.333333343267441,
0.333333343267441, 0.333333343267441, 0.333333343267441,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Pre Take-Up as Share of Invasive Services", format.stata = "%9.0g"),
pre_share4 = structure(c(0, 0, 0, 0, 0, 0.25, 0.25, 0.25,
0.25, 0.25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Pre Take-Up as Share of Four Services", format.stata = "%9.0g"),
delta_bmi = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Delta BMI: Post - Pre", format.stata = "%9.0g"),
delta_bp = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Delta Blood Pressure: Post - Pre", format.stata = "%9.0g"),
delta_dia = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Delta Diabetes: Post - Pre", format.stata = "%9.0g"),
delta_cho = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Delta Cholesterol: Post - Pre", format.stata = "%9.0g"),
delta_flu = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Delta Flu: Post - Pre", format.stata = "%9.0g"),
delta_shr_invasive = structure(c(0.666666686534882, 0.666666686534882,
0.666666686534882, 0.666666686534882, 0.666666686534882,
0.666666686534882, 0.666666686534882, 0.666666686534882,
0.666666686534882, 0.666666686534882, 0.333333343267441,
0.333333343267441, 0.333333343267441, 0.333333343267441,
0.333333343267441, 0, 0, 0, 0, 0), label = "Delta Take-Up as Share of Invasive Services", format.stata = "%9.0g"),
deltaind_test = structure(c(1, 1, 1, 1, 0, 1, 0, 1, 1, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0), label = "Indicator for Delta Selection - Stacked Subject X Test", format.stata = "%9.0g"),
delta_share4 = structure(c(1, 1, 1, 1, 1, 0.75, 0.75, 0.75,
0.75, 0.75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Delta as Share of Four Services", format.stata = "%9.0g"),
friends_enrolled = structure(c(NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 0, 0, 0, 0, 0, NA, NA, NA, NA, NA), label = "Are Friends Enrolled in the Study - CTO Patient Survey", format.stata = "%8.0g", labels = c(No = 0,
Yes = 1, Unsure = 99), class = c("haven_labelled", "vctrs_vctr",
"double")), value_bmi = structure(c(25, 25, 25, 25, 25, 28,
28, 28, 28, 28, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Patient Test Value: bmi - Encounter Survey", format.stata = "%10.0g"),
value_dia = structure(c(5.9, 5.9, 5.9, 5.9, 5.9, 6.9, 6.9,
6.9, 6.9, 6.9, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Patient Test Value: hgb - Encounter Survey", format.stata = "%10.0g"),
value_cho = structure(c(208, 208, 208, 208, 208, 170, 170,
170, 170, 170, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Patient Test Value: cho - Encounter Survey", format.stata = "%10.0g"),
subject_talk = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Subject Tried to Talk About Other Health Problems - Encounter Survey", format.stata = "%10.0g"),
choice_care = structure(c(3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2,
2, 2, 2, 2, 3, 3, 3, 3, 3), label = "How Much Choice Subj Has in Choice of Medical Care - Barber Survey", format.stata = "%22.0g", labels = c(`prefer not to answer` = -99,
`don't know` = -98, `a great deal of choice` = 1, `some choice` = 2,
`very little choice` = 3, `no choice` = 4), class = c("haven_labelled",
"vctrs_vctr", "double")), rating = structure(c(4, 4, 4, 4,
4, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, NA, NA, NA, NA, NA), label = "Experience Rating (1 = Bad, 5 = Excellent) - Subject Feedback", format.stata = "%10.0g"),
doctor_id = structure(c("BL6", "BL6", "BL6", "BL6", "BL6",
"NB8", "NB8", "NB8", "NB8", "NB8", "NB4", "NB4", "NB4", "NB4",
"NB4", "NB4", "NB4", "NB4", "NB4", "NB4"), label = "Doctor Mask ID", format.stata = "%9s"),
nonpreventive_agree = structure(c(0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Doctor Notes Relating to Personal/Other Health (Coders Agree) - Encounter Survey", format.stata = "%9.0g"),
mecherror_cho = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Mechanical Error, Cholesterol Test - Encounter Survey", format.stata = "%9.0g"),
mecherror_dia = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Mechanical Error, Diabetes Test - Encounter Survey", format.stata = "%9.0g"),
value_systolic = structure(c(165, 165, 165, 165, 165, 168,
168, 168, 168, 168, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA
), label = "Blood Pressure Value: Systolic - Encounter Survey", format.stata = "%9.0g"),
hyptension = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Subj Has Hypertension, Test Value or MD Comments - Encounter Survey", format.stata = "%9.0g"),
diabetic = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Subj Has Diabetes, Test Value or MD Comments - Encounter Survey", format.stata = "%9.0g"),
highcho = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA), label = "Subj Has High Cholesterol, Test Value or MD Comments - Encounter Survey", format.stata = "%9.0g"),
obese = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA), label = "Subj Is Obese, Test Value or MD Comments - Encounter Survey", format.stata = "%9.0g"),
length_visit_dr = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = "Doctor Visit Duration, Time Out of Waiting Room to Time Out - Encounter Survey", format.stata = "%9.0g"),
RO_tablet_assist = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = "RO Assisted Subject with Tablet Survey - Encounter Survey", format.stata = "%9.0g"),
yes_recommend = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, NA, NA, NA, NA, NA), label = "Patient Would Recommend Doctor - Subject Feedback", format.stata = "%9.0g"),
dr_notes = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1), label = "Doctor Wrote Notes in 'Notable' About Subject - Encounter Survey", format.stata = "%9.0g"),
any_health_prob = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1), label = "Subject Reported Any Health Problems (A2-A11) - Barber Survey", format.stata = "%9.0g"),
hosp_visits_2years = structure(c(NA, NA, NA, NA, NA, 3, 3,
3, 3, 3, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3), label = "Number of Hospital Visits in Last 2 Years - CTO Survey", format.stata = "%9.0g"),
ER_2years = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 7, 7, 7, 7, 7), label = "Number of ER Visits in Last 2 Years - Barber Survey", format.stata = "%9.0g"),
nights_hosp_2years = structure(c(0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Nights in the Hospital in Last 2 Years - Barber Survey", format.stata = "%9.0g"),
has_PCP = structure(c(0, 0, 0, 0, 0, -9, -9, -9, -9, -9,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = "Subject Has Primary Care Provider - Barber Survey", format.stata = "%9.0g"),
uninsured = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, -9,
-9, -9, -9, -9, 0, 0, 0, 0, 0), label = "Subject is Uninsured - Barber Survey", format.stata = "%9.0g"),
ER_visits_uninsured = structure(c(NA, NA, NA, NA, NA, 0,
0, 0, 0, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Number of ER Visits in Last 2 Years for Uninsured - Barber Survey", format.stata = "%9.0g"),
mistrust_5levels = structure(c(3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4), label = "Doctor Mistrust (1 is Lowest, 5 is Highest) - Barber Survey", format.stata = "%9.0g"),
med_mistrust = structure(c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1, 1, 1, 1, 1, 3, 3, 3, 3, 3), label = "Doctor Mistrust (1 is Lowest, 3 is Highest) - Barber Survey", format.stata = "%9.0g"),
age = structure(c(50, 50, 50, 50, 50, 44, 44, 44, 44, 44,
33, 33, 33, 33, 33, 35, 35, 35, 35, 35), label = "Subject Age - Barber Survey", format.stata = "%9.0g"),
age2 = structure(c(2500, 2500, 2500, 2500, 2500, 1936, 1936,
1936, 1936, 1936, 1089, 1089, 1089, 1089, 1089, 1225, 1225,
1225, 1225, 1225), label = "Subject Age Squared - Barber Survey", format.stata = "%9.0g"),
married = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Subject Is Married - Barber Survey", format.stata = "%9.0g"),
unemployed = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Subject Is Unemployed - Barber Survey", format.stata = "%9.0g"),
benefits = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Subject Receives DI/SSI/UB - Barber Survey", format.stata = "%9.0g"),
sl0 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1), label = "Subsidy Level: $0 - CTO Survey", format.stata = "%9.0g"),
sl5 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 0, 0, 0, 0, 0), label = "Subsidy Level: $5 - CTO Survey", format.stata = "%9.0g"),
sl10 = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0), label = "Subsidy Level: $10 - CTO Survey", format.stata = "%9.0g"),
subsidy_level = structure(c(10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0), label = "Subsidy Level, Categorical - CTO Survey", format.stata = "%9.0g"),
black_dr = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Randomized to Black Doctor - CTO Survey", format.stata = "%9.0g"),
black0 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doctor & Subsidy Level: $0 - CTO Survey", format.stata = "%9.0g"),
black5 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doctor & Subsidy Level: $5 - CTO Survey", format.stata = "%9.0g"),
black10 = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doctor & Subsidy Level: $10 - CTO Survey", format.stata = "%9.0g"),
white0 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1), label = "White Doctor & Subsidy Level: $0 - CTO Survey", format.stata = "%9.0g"),
white5 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
1, 1, 1, 0, 0, 0, 0, 0), label = "White Doctor & Subsidy Level: $5 - CTO Survey", format.stata = "%9.0g"),
white10 = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "White Doctor & Subsidy Level: $10 - CTO Survey", format.stata = "%9.0g"),
any_subsidy = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Subject Received $5 or $10 Subsidy - CTO Survey", format.stata = "%9.0g"),
age5 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0), label = "Subject Age Within 5 Years of Doctor's Age - Baseline Survey", format.stata = "%9.0g"),
age10 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0), label = "Subject Age Within 10 Years of Doctor's Age - Baseline Survey", format.stata = "%9.0g"),
educ_conc = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Education Concordance: Subject Has BA or Higher - Baseline Survey", format.stata = "%9.0g"),
good_sa_health = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Subject Rated Health as Good, Very Good, or Excellent - Barber Survey", format.stata = "%9.0g"),
no_rec_scr_interval = structure(c(1, 1, 1, 1, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Subject No Recent Screenings in Recommended Interval - Barber Survey", format.stata = "%9.0g"),
millenial = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1), label = "Subject Is Less Than 40 - Barber Survey", format.stata = "%9.0g"),
HSless = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 0, 0, 0, 0, 0), label = "Subject Has a High School Degree or Less - Barber Survey", format.stata = "%9.0g"),
low_income = structure(c(0, 0, 0, 0, 0, -9, -9, -9, -9, -9,
0, 0, 0, 0, 0, 1, 1, 1, 1, 1), label = "Household Has Income Below $5k/Year - Barber Survey", format.stata = "%9.0g"),
long_wait = structure(c(NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_), label = "Subject Waited Longer Than 1 Hour to See Doctor - Barber Survey", format.stata = "%9.0g"),
high_congestion = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = "More Than 8 People in Waiting Room When Subject Arrived - Congestion", format.stata = "%9.0g"),
long_driv = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Commute Via Car Above Median (18 Mins) - Barber Distance", format.stata = "%9.0g"),
atrisk_cho = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 1, 1, 1, 1, 1), label = "Subject Recommended to Get Cholesterol Test - CTO Survey", format.stata = "%9.0g"),
atrisk_dia = structure(c(NA, NA, NA, NA, NA, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Subject Recommended to Get Diabetes Test - CTO Survey", format.stata = "%9.0g"),
excuses = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1), label = "Subject Gave Excuse for Not Receiving Services - Suubject Feedback", format.stata = "%10.0g"),
length_dr_note = structure(c(9, 9, 9, 9, 9, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 61, 61, 61, 61, 61), label = "Length (Number of Characters) of Doctor Notes - Encounter Survey", format.stata = "%9.0g"),
mentioned_PCP = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Subject Mentioned PCP in Clinic Notes - Suubject Feedback", format.stata = "%9.0g"),
bl_ER_2years = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Number of ER Visits in Last 2 Years - Barber Survey", format.stata = "%9.0g"),
bl_med_mistrust = structure(c(2, 2, 2, 2, 2, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Doctor Mistrust (1 is Lowest, 3 is Highest) - Barber Survey", format.stata = "%9.0g"),
bl_millenial = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Is Less Than 40 - Barber Survey", format.stata = "%9.0g"),
bl_HSless = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Has a High School Degree or Less - Barber Survey", format.stata = "%9.0g"),
bl_low_income = structure(c(0, 0, 0, 0, 0, NA, NA, NA, NA,
NA, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Household Has Income Below $5k/Year - Barber Survey", format.stata = "%9.0g"),
bl_long_wait = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = "Black Doc * Subject Waited Longer Than 1 Hour to See Doctor - Barber Survey", format.stata = "%9.0g"),
bl_long_driv = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Commute Via Car Above Median (18 Mins) - Barber Distance", format.stata = "%9.0g"),
bl_high_congest = structure(c(NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_, NA_real_,
NA_real_, NA_real_, NA_real_, NA_real_, NA_real_), label = "Black Doc * More Than 8 People in Waiting Room When Subject Arrived - Congestion", format.stata = "%9.0g"),
bl_atrisk_cho = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Recommended to Get Cholesterol Test - CTO Survey", format.stata = "%9.0g"),
bl_atrisk_dia = structure(c(NA, NA, NA, NA, NA, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Recommended to Get Diabetes Test - CTO Survey", format.stata = "%9.0g"),
bl_no_rec_scr_interval = structure(c(1, 1, 1, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject No Recent Screenings in Recommended Interval - Barber Survey", format.stata = "%9.0g"),
bl_ER_visits_uninsured = structure(c(NA, NA, NA, NA, NA,
0, 0, 0, 0, 0, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), label = "Black Doc * Number of ER Visits in Last 2 Years for Uninsured - Barber Survey", format.stata = "%9.0g"),
bl_educ_conc = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Education Concordance: Subject Has BA or Higher - Baseline Survey", format.stata = "%9.0g"),
bl_age5 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Age Within 5 Years of Doctor's Age - Baseline Survey", format.stata = "%9.0g"),
bl_age10 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Age Within 10 Years of Doctor's Age - Baseline Survey", format.stata = "%9.0g"),
bl_sl10 = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subsidy Level: $10 - CTO Survey", format.stata = "%9.0g"),
RO_id = structure(c(6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3), label = "Blind ID, Reception Officer - Encounter Survey", format.stata = "%9.0g"),
location_id = structure(c(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
9, 9, 9, 9, 9, 9, 9, 9, 9), label = "Blind ID, Recruitment Location - Barber Survey", format.stata = "%9.0g"),
date_visit_id = structure(c(2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1), label = "Blind ID, Date of Clinic Visit - Encounter Survey", format.stata = "%9.0g"),
tag = structure(c(0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 1, 0), label = "Tag for Study ID", format.stata = "%8.0g"),
bmi_test = structure(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0,
0, 0, 0, 1, 0, 0, 0, 0), label = "Tag for BMI Test", format.stata = "%9.0g"),
bp_test = structure(c(0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 0, 1, 0, 0, 0), label = "Tag for Blood Pressure Test", format.stata = "%9.0g"),
dia_test = structure(c(0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1, 0, 0, 0, 0, 1, 0, 0), label = "Tag for Diabetes Test", format.stata = "%9.0g"),
cho_test = structure(c(0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 0, 0, 1, 0), label = "Tag for Cholesterol Test", format.stata = "%9.0g"),
flu_test = structure(c(0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1, 0, 0, 0, 0, 1), label = "Tag for Flu Shot", format.stata = "%9.0g"),
any_invasive = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Subject Chose At Least One Invasive Screening", format.stata = "%9.0g"),
bl_any_invasive = structure(c(1, 1, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Subject Chose At Least One Invasive Screening", format.stata = "%9.0g"),
preind_test = structure(c(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Indicator for Ex pre Selection - Stacked Subject X Test", format.stata = "%9.0g"),
postind_test = structure(c(1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0), label = "Indicator for Ex Post Selection - Stacked Subject X Test", format.stata = "%9.0g"),
bl_bp_test = structure(c(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Tag for Blood Pressure Test", format.stata = "%9.0g"),
bl_bmi_test = structure(c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Tag for BMI Test", format.stata = "%9.0g"),
bl_dia_test = structure(c(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Tag for Diabetes Test", format.stata = "%9.0g"),
bl_flu_test = structure(c(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Tag for Flu Shot", format.stata = "%9.0g"),
bl_cho_test = structure(c(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Black Doc * Tag for Cholesterol Test", format.stata = "%9.0g"),
missing_age = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for age", format.stata = "%9.0g"),
missing_HSless = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for HSless", format.stata = "%9.0g"),
missing_low_income = structure(c(0, 0, 0, 0, 0, 1, 1, 1,
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for low_income", format.stata = "%9.0g"),
missing_has_PCP = structure(c(0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for has_PCP", format.stata = "%9.0g"),
missing_uninsured = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0), label = "Missing Indicator for uninsured", format.stata = "%9.0g"),
missing_age2 = structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for age2", format.stata = "%9.0g"),
missing_good_sa_health = structure(c(0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), label = "Missing Indicator for good_sa_health", format.stata = "%9.0g")), row.names = c(NA,
-20L), class = c("tbl_df", "tbl", "data.frame"), label = "Main Oakland Clinic Analysis Dataset")
答案
我将geom_bar
更改为geom_histogram
,从而解决了该问题。这是可行的替代方法。
以上是关于带有NA值的吊图的主要内容,如果未能解决你的问题,请参考以下文章