2014年9月25日 2014年の世界全体および日本の地震発生状況(マグニチュード3.0以上について)


Data Source:U.S. Geological Survey http://earthquake.usgs.gov/earthquakes/

Sys.time()
## [1] "2014-09-25 21:05:31 JST"

Package

library(xts) # http://cran.r-project.org/web/packages/xts/xts.pdf
library(ggplot2) # http://cran.r-project.org/web/packages/ggplot2/ggplot2.pdf
library(gridExtra) #http://cran.r-project.org/web/packages/gridExtra/gridExtra.pdf
library(knitr) # http://cran.r-project.org/web/packages/knitr/knitr.pdf
library(googleVis) # http://cran.r-project.org/web/packages/googleVis/googleVis.pdf
library(xtable)
library(openair)# http://cran.r-project.org/web/packages/openair/openair.pdf
library(scales)

Read Data

data.file="query.csv"
username<-Sys.info()['user']
path01<-paste("C:/Users/",username,"/Desktop/Earthquake_Data/",sep="")
setwd(path01)
dataset<-read.table(file=paste(path01,data.file,sep=""),sep=",",header=T,as.is=T,skip=0)
dataset$jst.h<-as.POSIXct(sub("Z","",sub("T"," ",dataset$time)))+3600*9 #UTC+9 JST
dataset$jst.d<-as.Date(substr(dataset$jst.h,1,regexpr("\\s",dataset$jst)-1))
dataset.j<-dataset[grep("Japan",dataset[,14]),]
first.date<-as.Date("2014/1/1")
last.date<-Sys.Date()
all.date<-data.frame(date=seq(first.date,last.date,by="days"))
all.date.j<-all.date
for(ddd in 1:length(all.date[,1])){
all.date$NumberOfEarthquake[ddd]<-nrow(subset(dataset,all.date[,1][ddd]==dataset[,ncol(dataset)]))
all.date.j$NumberOfEarthquake[ddd]<-nrow(subset(dataset.j,all.date[,1][ddd]==dataset.j[,ncol(dataset)]))
}
nrow(dataset)
## [1] 14991
nrow(dataset.j)
## [1] 842
sum(all.date[,2])
## [1] 14991
sum(all.date.j[,2])
## [1] 842
head(dataset,1)
##                       time latitude longitude depth mag magType nst gap
## 1 2014-01-01T00:01:16.610Z    19.09     120.2 10.07 5.1      mb  NA  29
##    dmin  rms net         id                  updated
## 1 3.794 0.85  us usc000lv5e 2014-09-04T18:20:28.000Z
##                             place       type               jst.h
## 1 76km NNW of Davila, Philippines earthquake 2014-01-01 09:01:16
##        jst.d
## 1 2014-01-01
tail(dataset,1)
##                           time latitude longitude depth mag magType nst
## 14991 2014-09-25T10:55:10.070Z    18.83     145.4 241.2 4.7      mb  NA
##       gap  dmin  rms net         id                  updated
## 14991  77 3.594 1.07  us usb000sfuj 2014-09-25T11:14:15.300Z
##                                               place       type
## 14991 24km WNW of Agrihan, Northern Mariana Islands earthquake
##                     jst.h      jst.d
## 14991 2014-09-25 19:55:10 2014-09-25

Plot

calendarPlot(all.date,pollutant="NumberOfEarthquake",year=2014,cols="heat",main="Entire World in 2014")

plot of chunk unnamed-chunk-4

calendarPlot(all.date.j,pollutant="NumberOfEarthquake",year=2014,cols="heat",main="Japan in 2014")

plot of chunk unnamed-chunk-4

g<-ggplot(all.date,aes(x=date,y=NumberOfEarthquake))
g+geom_bar(stat="identity",fill="grey",alpha=0.5,color="black")+scale_x_date(labels=date_format("%y/%m/%d"))+ggtitle("Entire World")

plot of chunk unnamed-chunk-4

g<-ggplot(all.date.j,aes(x=date,y=NumberOfEarthquake))
g+geom_bar(stat="identity",fill="grey",alpha=0.5,color="black")+scale_x_date(labels=date_format("%y/%m/%d"))+ggtitle("Japan")

plot of chunk unnamed-chunk-4