Reputation: 43
I am trying to visualize (a) the distribution of a variable, and also (b)the proportion of one value of that variable compared to others.
In the example below, I want to make a histogram of health scores 1-5, and leave the '1-3' and '5' portions colored grey but color the '4' portion a bright color.
How could I do this?
I am using the packages tidyverse, plyr, and skimr and working in RStudio with cdc data.
Thank you!
recode <- mapvalues(cdc$genhlth, from = c("excellent", "very good", "good", "fair", "poor"), to = c("5", "4", "3", "2", "1"))
ggplot(cdc, aes(recode) +
geom_histogram() +
ggtitle("Distribution of General Health & Proportion of Very Good Health")
# then go back in here later and color the 4's
Upvotes: 0
Views: 63
Reputation: 111
A hackaround if this is case specific could be to add a second layer with geom_col(x=4,y=count at 4)
with the same width as the geom_histogram
Upvotes: 1