I am trying to combine two different bar graphs into one using GGPLOT. Seperately the code is `
ggplot(data=by_div_salaries, aes(x=women_salary, y=salaries.ClassificationName)) +
geom_bar(stat="identity") +labs(title = "Women Head Coach Salaries")
ggplot(data=by_div_salaries, aes(x=men_salary, y=salaries.ClassificationName)) +
geom_bar(stat="identity") +labs(title = "Men Head Coach Salaries")
and I am trying to get the mens salary next to the womens salary by having two bars for each ClassificationName.
I tried this:
ggplot(data=by_div_salaries, aes()) +
geom_bar(mapping = aes(x=women_salary, y=salaries.ClassificationName), position=position_nudge(x = 0.2), width=0.2,stat = "identity",color="green" ) +
geom_bar(mapping = aes(x=men_salary, y=salaries.ClassificationName), position=position_nudge(x = -0.2), width=.2, stat = "identity", color = "blue") +
scale_y_continuous(name = "Division") +
xlab("Salary")
But am getting this error:
Error: Discrete value supplied to continuous scale
I want the two grpahs next to each other.
scale_y_discreteinstead ofscale_y_continuous. My guess is thatsalaries.ClassificationNameis a catagorical column.