数据分析–用R语言预测离职(下)
接上一篇~
接下来我们探索离职和其他分类变量的关系~
> library(scales)
> k1 <- ggplot(attr.df, aes(x=Gender,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k2 <- ggplot(attr.df, aes(x=BusinessTravel,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k3 <- ggplot(attr.df, aes(x=Department,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k4 <- ggplot(attr.df, aes(x=EducationField,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k5 <- ggplot(attr.df, aes(x=MaritalStatus,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k6 <- ggplot(attr.df, aes(x=OverTime,fill=Attrition))+
+ geom_bar(position = "fill")+
+ labs(y="Percentage")+scale_y_continuous(labels = percent)
> k7 <- ggplot(attr.df, aes(