library(openxlsx) library(ggplot2) library(gridExtra) sample1<-read.xlsx("http://kanggc.iptime.org/book/data/sample1-n.xlsx") year<-sample1$year gdp<-sample1$gdp consumption<-sample1$consumption plot1<-ggplot(data=sample1, aes(x=year, y=gdp, group=1)) + geom_line() + ggtitle("GDP of Korea(2000-2016)")+ theme(plot.title = element_text(hjust = 0.5)) plot2<-ggplot(data=sample1, aes(x=year, y=consumption, group=1)) + geom_line() + ggtitle("Consumption of Korea(2000-2016)") + theme(plot.title = element_text(hjust = 0.5)) marrangeGrob(grobs=list(plot1, plot2), nrow=2, ncol=1) plot3<-ggplot(data=sample1, aes(x=gdp)) + geom_histogram(fill="white",bins=8) + ggtitle("Histogram of GDP")+ theme(plot.title = element_text(hjust = 0.5)) plot4<-ggplot(data=sample1, aes(x=consumption)) + geom_histogram(fill="red",bins=8) + ggtitle("Histogram of Consumption") + theme(plot.title = element_text(hjust = 0.5)) marrangeGrob(grobs=list(plot3, plot4), nrow=2, ncol=1) plot5<-ggplot(data=sample1, aes(x=gdp, y=consumption)) + geom_point(colour="red", size=2) + ggtitle("Scatter plot of GDP and Consumption")+ theme(plot.title = element_text(hjust = 0.5)) marrangeGrob(grobs=list(plot5), nrow=1, ncol=1)