my code:
ggplot(data)+
geom_bar(aes(x=data$AgeGroup, y=data$NumberofLoans), stat="identity")+
geom_line(aes(x=data$AgeGroup, y=data$BadRate*max(data$NumberofLoans)) , stat="identity",group=1)+
scale_y_continuous(sec.axis = sec_axis(~./max(data$NumberofLoans)))
can anyone help me out to get the second graph as the answer. Currently i am getting the first graph
Data:
AgeGroup,NumberofLoans,BadLoans,GoodLoans,BadRate
21-24,310,14,296,4.5
24-27,511,20,491,3.9
27-30,4000,172,3828,4.3
30-33,4568,169,4399,3.7
33-36,5698,188,5510,3.3
36-39,8209,197,8012,2.4
39-42,8117,211,7906,2.6
42-45,9000,216,8784,2.4
45-48,7600,152,7448,2
48-51,6000,84,5916,1.4
51-54,4000,64,3936,1.6
54-57,2000,26,1974,1.3
57-60,788,9,779,1.1