library(ggplot2) library(grid) library(gridExtra) library(scales) epw = "~/weather-datasets/GBR_London-Heathrow.AP.1989_2080High90pct_CIBSETM49.epw" system(paste("cat ",epw, "| tail -8760 > test.csv")) EPW <- read.csv("test.csv", header=FALSE) EPW$OAT = EPW[,7] EPW$RH = EPW[,9] EPW$MDH <- paste(EPW$V2,EPW$V3,EPW$V4) EPW$M = as.POSIXlt(EPW$MDH,format="%m") EPW$DT = as.POSIXlt(EPW$MDH,format="%m %d %H") EPW$HR = as.numeric(format(EPW$DT, "%H")) EPW$hum_ratio=((2.16679*((610.78*exp((EPW$OAT/(EPW$OAT+238.3))*17.2694))*(EPW$RH/100)/(273.15+EPW$OAT)))/1275.4) temps <- data.frame() for (i in 0:23) {temps <- rbind(temps,c( i, mean(subset(subset(EPW, HR==i), format(DT,'%m')=='12')$OAT), mean(subset(subset(EPW, HR==i), format(DT,'%m')=='03')$OAT), mean(subset(subset(EPW, HR==i), format(DT,'%m')=='06')$OAT), mean(subset(subset(EPW, HR==i), format(DT,'%m')=='09')$OAT))) } colnames(temps) <- c("hr", "temp_dec", "temp_mar", "temp_jun", "temp_sep") pdf("plots.pdf") #ggplot(diamonds, aes(x=carat, y=price)) + geom_point() p1 = ggplot(temps, aes(x=hr, y=temp_dec)) + geom_line() + scale_y_continuous(limits = c(5, 30)) p2 = ggplot(temps, aes(x=hr, y=temp_mar)) + geom_line() + scale_y_continuous(limits = c(5, 30)) p3 = ggplot(temps, aes(x=hr, y=temp_jun)) + geom_line() + scale_y_continuous(limits = c(5, 30)) p4 = ggplot(temps, aes(x=hr, y=temp_sep)) + geom_line() + scale_y_continuous(limits = c(5, 30)) grid.arrange(p1, p2, p3, p4, ncol = 2) dev.off()