Skip to content

Instantly share code, notes, and snippets.

@rshyam1
Created May 1, 2016 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rshyam1/f1107bac4aaa493bd61b689cb6c273e3 to your computer and use it in GitHub Desktop.
Save rshyam1/f1107bac4aaa493bd61b689cb6c273e3 to your computer and use it in GitHub Desktop.
# changing "sex" numerical values to factors
sex_vec=c(1,2)
sex_desc=c("male","female")
credi_tbl_temp$SEX=factor(x=credit_tbl$SEX,levels=sex_vec,labels=sex_desc)
# Creating Bar Plots for Gender as factors for fill and default as factor on x-axis
s=ggplot(data = credi_tbl_temp, aes(x = default.payment.next.month)) +
geom_bar(aes (fill = SEX), position = "fill") +
ggtitle("Gender Profile of Default Payment Vs Non-Default")+
xlab("")+ylab("")
s
s1=ggplot(data = credi_tbl_temp, aes(x = default.payment.next.month)) +
geom_bar(aes (fill = SEX), position = "dodge") +
ggtitle("Gender Profile of Default Payment Vs Non-Default")+
xlab("")+ylab("")
s1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment