She wants to find out crimes in the USA for various states. So she plots the data set "USArrests" to construct a bar chart of the number of murders in different states.
Following command is giving error : ggplot(USArrests, aes(x = row.names(USArrests), y = USArrests$Murder, lab)) + geom_bar() + theme(axis.text.x=element_text(angle=90, hjust=1))
Error : "stat_count() must not be used with a y aesthetic". What can she do to correct this?
- Should I remove row.names — it should be x = USArrests$State ??
- Should I use theme(axis.angle.x = 90) instead of current one?
- Will geom_histogram() be better than Geom_bar?
- Or Should I use geom_col() instead of geom_bar()?
Please do suggest correct command. Thanks