# Entering data
year <- c(2014, 2015, 2016, 2017, 2018, 2019,2020)
course <- c(35, 30, 40, 25, 30, 35, 65)
penroll <- c(0.3, 0.25, 0.3, 0.5, 0.4, 0.2, 0.6)
# Creating Data Frame
perf <- data.frame(year, course, penroll)
# Plotting Multiple Charts and changing
# secondary axis to percentage
library(ggplot2)
ggp <- ggplot(perf) +
geom_bar(aes(x=year, y=course),stat="identity", fill="cyan",colour="#006000")+
geom_line(aes(x=year, y=100*penroll),stat="identity",color="red",size=2)+
labs(title= "Courses vs Students Enrolled in GeeksforGeeks",
x="Year",y="Number of Courses Sold")+
scale_y_continuous(sec.axis=sec_axis(
~.*0.01,name="Percentage of Students Enrolled", labels=scales::percent))
ggp