I am trying to create 3 plots for categorical vs categorical variables. I am not seeing any legend for different categories of variables C1,C4,C5. Also the bars are greyed out. The dataset has information on 9 categorical variables and 6 numerical variables. C1,C4,C5 has 2,4,3 categories respectively. Hired (1,0) is the variable showing if a candidate will be hired or not.
install.packages("Rmisc")
library(Rmisc)
p1<-ggplot(hireouti, aes(x = Hired, fill = C1)) + geom_bar(position = 'stack', show.legend=TRUE)
p2<-ggplot(hireouti, aes(x = Hired, fill = C4)) + geom_bar(position = 'stack', show.legend=TRUE)
p3<-ggplot(hireouti, aes(x = Hired, fill = C5)) + geom_bar(position = 'stack', show.legend=TRUE)
multiplot(p1,p2,p3, cols = 3)
The first visualisation below is the output I am getting. I would like to obtain a visualisation like the second one below.
I have been able to reproduce the visualisation with legend.
I have executed the code below and C1,C4,C5 were numeric. I have tried converting into factor.
p1<-ggplot(hireouti, aes(x = Hired, fill = factor(C1))) + geom_bar(position = 'stack', show.legend = TRUE)
p2<-ggplot(hireouti, aes(x = Hired, fill = factor(C4))) + geom_bar(position = 'stack', show.legend = TRUE)
p3<-ggplot(hireouti, aes(x = Hired, fill = factor(C5))) + geom_bar(position = 'stack', show.legend = TRUE)
multiplot(p1,p2,p3, cols = 3)