library(RSQLite) drv <- dbDriver("SQLite") dbfile <- "weather.db" con <- dbConnect(drv, dbfile) dbListTables(con) res <- dbGetQuery(con, "SELECT * FROM table1 WHERE datetime LIKE '2010-08-%';") head(res);tail(res) x<-as.POSIXlt(res[,1]) r <-as.POSIXlt(range(x)) r1 <-as.Date(range(x)) title<-paste("鳥取市",r1[1],"~",r1[2]) par(mar = c(3,7,3,6),mfrow=c(2,1),cex.axis=0.9,family="TakaoMincho") plot(x,res$temperature,xaxt="n",xlab = "Date", ylab = "", main = title,las = 1,type="l",col="red") grid(NA,NULL,lty=3) axis.POSIXct(1, at=seq(r[1],r[2],by="1 days"), format="%m/%d") mtext("気温(℃)", side=2, line=3) abline(v=seq(r[1],r[2], by="5 days"),lty=3,col="gray") par(new=T) plot(x,res$precipitation,xaxt="n",xlab="",yaxt="n",ylab="",type="h",ylim=c(0,40),col="blue",main="") axis(4,las=1) mtext("降水量(mm)", side=4, line=3) plot(x,res$pressure,xaxt="n",xlab="",ylab="気圧(hP)",type="l",col="green",ylim=c(NULL,NULL),main="",las=1) grid(NA,NULL,lty=3) axis.POSIXct(1, at=seq(r[1],r[2], by="1 days"), format="%m/%d") abline(v=seq(r[1],r[2], by="5 days"),lty=3,col="gray") par(mfrow=c(1,1))
|