Created
March 14, 2011 14:41
-
-
Save koh-t/869219 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 初回実行時には以下のコメントアウトを外してください。 | |
## ----------------- setting ---------------------- | |
## パッケージのダウンロード先を変更します | |
## options(repos="http://cran.cnr.berkeley.edu/") | |
## zooライブラリをインストールします | |
## install.packages("zoo") | |
## ------------------------------------------------- | |
## ライブラリ呼びこみ | |
library(zoo) | |
## データの読み込み | |
dat <- read.csv("Fukushima1.csv") | |
## zooでは観測時刻と観測点を指定することで、データをまとめます | |
## 計測時間の調整。12:30が1230と今回のデータでは記載されているので整形します | |
## 1日目の計測時刻の処理 | |
time1 <- dat[1:73,1] | |
h1 <- time1%/%100 ## 割り算の結果から時間[hour]を抜き出します | |
m1 <- time1%%100 ## 分[minuts]を抜き出します | |
time.a <- (h1*60 + m1) / 60 ## 時間を単位にして計測時刻を算出 | |
## 2日目の計測時刻の処理 | |
time2 <- dat[74:180,1] | |
h2 <- time2%/%100 + 24 ## 2日目は24時間遅らせます | |
m2 <- time2%%100 | |
time.b <- (h2*60 + m2) / 60 | |
## 2日分の時刻時刻の結合 | |
time2 <- c(time.a,time.b) | |
## zoo形式のデータを作ります | |
## x: 計測値, order.by: 計測時刻 | |
plotdat <- zoo(x=dat[,4],order.by=time2) | |
## プロットします。 | |
## type="h"をtype="o"に変更すると、計測点間を直線で繋ぎます | |
plot(plotdat,type="h",axes=FALSE,col=4,lwd=2, | |
xlab="Time[hour], from '3/12/2010 4:00' to '3/13/2010 18:00'", | |
ylab="Gamma ray [uSv/h]",main="Fukushima nuclear power plant, No.1") | |
## 軸とメモリの描写を値を指定して行います。 | |
## 上記plotの引数、axes=FALSEをaxes=TRUEに変更すると、自動で行われます | |
axis(side=1,at=4:36) | |
axis(side=2,at=c(100,200,300,400)) | |
## 日付変更線を描きます | |
abline(v=24,lty=2,lwd=2) | |
## 日にちを図上に表示します | |
text(x=20,y=360,labels="3/12",cex=2.5) | |
text(x=28,y=360,labels="3/13",cex=2.5) | |
## 図示した画像を保存します | |
dev.copy2eps(file="001h.eps") ## eps形式 | |
##dev.copy2pdf(file="001h.png") ## pdf形式 | |
## 環境によってはpngやjpegで保存できます | |
## png(filename = "graphic.png", width = 480, height = 480) | |
## http://www.okada.jp.org/RWiki/index.php?R%BD%D0%CE%CF%A4%CE%B5%AD%CF%BF#o8f76a1a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment