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 gdp consumption qp1<-qplot(gdp, bins=8, geom="auto") qp2<-qplot(consumption, bins=8, geom="auto") marrangeGrob(grobs=list(qp1, qp2), nrow=2, ncol=1) plot1<-ggplot(data=sample1, aes(x=gdp)) + geom_histogram(fill="white",bins=8) + ggtitle("Histogram of GDP")+ theme(plot.title = element_text(hjust = 0.5)) plot2<-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(plot1, plot2), nrow=2, ncol=1)