In the assignment I am doing, it wants me to use geom_boxplot. However, I have been unable to get the graph to display the boxplots correctly.
# Convert To Factor
census_data$CIT <- as.factor(census_data$CIT)
class(census_data$CIT)
ggplot(census_data, aes(census_data[["VALP"]], (census_data[["CIT"]])) +
geom_boxplot(color = "blue", fill = "orange") +
ggtitle("Property value by citizenship status") +
xlab("“Citizenship status") + ylab("Property value")
I am slightly concerned that the CIT may not have been converted correctly to a factor.
I think you have your x
and y
aesthetics the wrong way around. you have VALP
first which is then assumed to be x
and CIT
second which is asssumed to be y
. Given your labels I think you want them in the other order.
I always find it helps to label them explicitly, ie aes(x=.., y=...)
so you don't get confused!
You also don't need to use census_data[["VALP"]]
in the aes
function call, since you have supplied the census_data
in the data argument just saying aes(x=CIT, y=VALP)
should be enough.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.