I have a dataframe called "employee_attrition". There are two variables of my interest, the first one is called "MonthlyIncome" (with continuous data of salary) and the second one is "PerformanceRating" which takes discrete values (1,2,3 or 4). My intention is to create a histogram for the MonthlyIncome, and show the PerformanceRating in the same plot. I have this:
ggplot(data = employee_attrition, aes(x=MonthlyIncome, fill=PerformanceRating))+
geom_histogram(aes(y=..count..))+
xlab("Salario mensual (MonthlyIncome)")+
ylab("Frecuencia")+
ggtitle("Histograma: MonthlyIncome y Attrition")+
theme_minimal()
The problem is that the plot does not show the "PerformanceRating" associated with each bar of the histogram.
My data frame is something like this:
MonthlyIncome PerformanceRating
1 5993 1
2 5130 1
3 2090 4
4 2909 3
5 3468 4
6 3068 3
And i want a histogram that shows the frequency of MonthlyIncome and each bar with 4 colours of the PerformanceRating.
Something like this, but with 4 colours (PerformanceRating Values)