Hi! I have this code where I want to replace the NA at the bottom of the chart with the age range that I have coded. For some reason it does not work. Any ideas on how to fix this without having to change my entire assignment? Here is the code:
nobel_winners["Age_Range"] = cut(nobel_winners$Age_Range, c(0, 30, 44,60, 75, Inf), c("0-30", "31-44", "45-59", "46-74", ">74"), include.lowest = TRUE)
nobel_winners$Age_Range <- factor( nobel_winners$Age_Range ,
levels=c("Not Appl (Organisation)","Less than 30 yo", "30-44 yo", "45-59 yo","60-74 yo", "75 yo or more"))
#Plot3 - Number of Nobel Prizes by Age Range
ggplot(nobel_winners, aes( x = Age_Range, fill = gender)) +
geom_bar() + scale_fill_brewer(palette = "Set2") +
facet_wrap(~ category ) +
labs(title = "Number of Nobel Prizes by Age Range and Gender") +
xlab("Age Range When Awarded") +
ylab("Awarded Prizes") +
theme(axis.text.x = element_text(angle = 55, hjust = 1),
axis.title.x = element_text(size = 12),
axis.title.y = element_text(size = 12),
plot.title = element_text(size = 15, face = "bold"))