マグニチュード6.0以上の地震の1900年1月以降月間発生回数:世界全体と日本


Data Source:U.S. Geological Survey http://earthquake.usgs.gov/earthquakes/feed/v1.0/csv.php

Sys.time()
## [1] "2014-09-26 19:45:24 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(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("1900/1/1")
last.date<-Sys.Date()+31
all.date<-data.frame(date=seq(first.date,last.date,by="months"))
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[,1][ddd+1]>dataset[,ncol(dataset)]))
all.date.j$NumberOfEarthquake[ddd]<-nrow(subset(dataset.j,all.date.j[,1][ddd]<=dataset.j[,ncol(dataset.j)] & all.date.j[,1][ddd+1]>dataset.j[,ncol(dataset.j)]))
}

Plot

ggplot(all.date,aes(x=date,y=NumberOfEarthquake))+geom_line(stat="identity",color="blue")+scale_x_date(labels=date_format("%Y/%b"))+xlab("Date")+ggtitle("Entire World")

plot of chunk unnamed-chunk-4

ggplot(all.date.j,aes(x=date,y=NumberOfEarthquake))+geom_line(stat="identity",color="red")+scale_x_date(labels=date_format("%Y/%b"))+xlab("Date")+ggtitle("Japan")

plot of chunk unnamed-chunk-4

Max

row.id<-which(max(all.date[,2])==all.date[,2])
print(paste("Max EntireWorld ",format(all.date[,1][row.id],"%Y/%b")," n=",max(all.date[,2]),sep=""))

[1] “Max EntireWorld 2011/3 n=74”

row.id<-which(max(all.date.j[,2])==all.date.j[,2])
print(paste("Max Japan ",format(all.date.j[,1][row.id],"%Y/%b")," n=",max(all.date.j[,2]),sep=""))

[1] “Max Japan 2011/3 n=62”

japan<-subset(dataset.j,as.Date("2011/3/1")<=dataset.j[,ncol(dataset.j)] & as.Date("2011/4/1")>dataset.j[,ncol(dataset.j)])
kable(cbind(japan[,c(16,14,5)],no=seq(1:length(japan[,1]))))
jst.hplacemagno
79102011-03-09 11:45:20near the east coast of Honshu, Japan7.31
79112011-03-10 03:16:16near the east coast of Honshu, Japan6.02
79122011-03-10 06:22:17near the east coast of Honshu, Japan6.03
79132011-03-10 06:24:01near the east coast of Honshu, Japan6.54
79162011-03-11 14:46:24near the east coast of Honshu, Japan9.05
79172011-03-11 14:54:31near the east coast of Honshu, Japan6.36
79182011-03-11 14:55:45off the east coast of Honshu, Japan6.47
79192011-03-11 14:58:07off the east coast of Honshu, Japan6.38
79202011-03-11 15:00:39near the east coast of Honshu, Japan6.29
79212011-03-11 15:06:13near the east coast of Honshu, Japan6.310
79222011-03-11 15:07:20near the east coast of Honshu, Japan6.411
79232011-03-11 15:08:29off the east coast of Honshu, Japan6.712
79242011-03-11 15:12:36off the east coast of Honshu, Japan6.213
79252011-03-11 15:13:01near the east coast of Honshu, Japan6.214
79262011-03-11 15:15:23off the east coast of Honshu, Japan6.315
79272011-03-11 15:15:40near the east coast of Honshu, Japan7.916
79282011-03-11 15:18:49off the east coast of Honshu, Japan6.617
79292011-03-11 15:20:04off the east coast of Honshu, Japan6.518
79302011-03-11 15:21:32near the east coast of Honshu, Japan6.219
79312011-03-11 15:23:09near the east coast of Honshu, Japan6.220
79322011-03-11 15:25:50off the east coast of Honshu, Japan7.721
79332011-03-11 15:29:15off the east coast of Honshu, Japan6.122
79342011-03-11 15:48:45off the east coast of Honshu, Japan6.223
79352011-03-11 15:49:16off the east coast of Honshu, Japan6.124
79362011-03-11 15:57:16near the east coast of Honshu, Japan6.025
79372011-03-11 15:59:00off the east coast of Honshu, Japan6.326
79382011-03-11 16:14:58near the east coast of Honshu, Japan6.327
79392011-03-11 16:25:36off the east coast of Honshu, Japan6.128
79402011-03-11 16:28:12near the east coast of Honshu, Japan6.129
79412011-03-11 16:29:01near the east coast of Honshu, Japan6.330
79422011-03-11 16:30:18near the east coast of Honshu, Japan6.031
79432011-03-11 17:12:07near the east coast of Honshu, Japan6.232
79442011-03-11 17:15:41off the east coast of Honshu, Japan6.133
79452011-03-11 17:19:24near the east coast of Honshu, Japan6.534
79462011-03-11 17:26:36off the east coast of Honshu, Japan6.135
79472011-03-11 17:27:51near the east coast of Honshu, Japan6.036
79482011-03-11 17:31:09near the east coast of Honshu, Japan6.037
79492011-03-11 17:33:00near the east coast of Honshu, Japan6.038
79502011-03-11 19:10:34near the east coast of Honshu, Japan6.039
79512011-03-11 20:36:40near the east coast of Honshu, Japan6.640
79522011-03-12 00:13:14near the east coast of Honshu, Japan6.341
79532011-03-12 00:20:08near the east coast of Honshu, Japan6.042
79542011-03-12 03:59:16near the west coast of Honshu, Japan6.243
79552011-03-12 04:02:59near the east coast of Honshu, Japan6.044
79562011-03-12 04:46:50near the west coast of Honshu, Japan6.245
79572011-03-12 05:11:24near the east coast of Honshu, Japan6.146
79582011-03-12 10:47:15off the east coast of Honshu, Japan6.547
79592011-03-12 22:15:41near the east coast of Honshu, Japan6.148
79602011-03-13 08:24:48near the east coast of Honshu, Japan6.149
79612011-03-13 10:26:04near the east coast of Honshu, Japan6.150
79622011-03-14 15:12:36off the east coast of Honshu, Japan6.051
79632011-03-15 22:27:56off the east coast of Honshu, Japan6.052
79642011-03-15 22:31:46eastern Honshu, Japan6.053
79652011-03-16 00:23:53off the east coast of Honshu, Japan6.154
79672011-03-17 13:13:56near the east coast of Honshu, Japan6.255
79692011-03-22 16:18:45off the east coast of Honshu, Japan6.456
79702011-03-22 18:19:06near the east coast of Honshu, Japan6.157
79712011-03-22 18:44:29off the east coast of Honshu, Japan6.458
79732011-03-25 20:36:24near the east coast of Honshu, Japan6.259
79762011-03-28 07:23:58near the east coast of Honshu, Japan6.260
79772011-03-29 19:54:33off the east coast of Honshu, Japan6.161
79792011-03-31 16:15:30near the east coast of Honshu, Japan6.062

Part of Data

summary(dataset)
##      time              latitude        longitude          depth      
##  Length:8485        Min.   :-71.00   Min.   :-180.0   Min.   :  0.0  
##  Class :character   1st Qu.:-16.06   1st Qu.: -72.4   1st Qu.: 15.0  
##  Mode  :character   Median : -0.29   Median : 119.0   Median : 31.7  
##                     Mean   :  5.11   Mean   :  46.6   Mean   : 76.1  
##                     3rd Qu.: 32.75   3rd Qu.: 146.3   3rd Qu.: 56.2  
##                     Max.   : 84.96   Max.   : 180.0   Max.   :720.0  
##                                                                      
##       mag         magType               nst           gap      
##  Min.   :6.00   Length:8485        Min.   :  0   Min.   :  9   
##  1st Qu.:6.20   Class :character   1st Qu.: 63   1st Qu.: 18   
##  Median :6.50   Mode  :character   Median :221   Median : 24   
##  Mean   :6.56                      Mean   :245   Mean   : 30   
##  3rd Qu.:6.90                      3rd Qu.:371   3rd Qu.: 37   
##  Max.   :9.60                      Max.   :999   Max.   :230   
##  NA's   :1                         NA's   :372   NA's   :7294  
##       dmin           rms           net                 id           
##  Min.   : 0     Min.   :0      Length:8485        Length:8485       
##  1st Qu.: 1     1st Qu.:1      Class :character   Class :character  
##  Median : 3     Median :1      Mode  :character   Mode  :character  
##  Mean   : 4     Mean   :1                                           
##  3rd Qu.: 5     3rd Qu.:1                                           
##  Max.   :26     Max.   :2                                           
##  NA's   :8229   NA's   :7223                                        
##    updated             place               type          
##  Length:8485        Length:8485        Length:8485       
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##      jst.h                         jst.d           
##  Min.   :1900-01-06 04:00:00   Min.   :1900-01-06  
##  1st Qu.:1957-04-25 04:10:12   1st Qu.:1957-04-25  
##  Median :1983-03-20 22:45:50   Median :1983-03-20  
##  Mean   :1976-02-24 21:19:01   Mean   :1976-02-24  
##  3rd Qu.:2001-01-11 01:02:43   3rd Qu.:2001-01-11  
##  Max.   :2014-09-26 02:51:17   Max.   :2014-09-26  
## 
summary(dataset.j)
##      time              latitude      longitude       depth      
##  Length:732         Min.   :22.0   Min.   :123   Min.   :  0.0  
##  Class :character   1st Qu.:31.2   1st Qu.:138   1st Qu.: 23.0  
##  Mode  :character   Median :36.4   Median :141   Median : 35.0  
##                     Mean   :35.4   Mean   :139   Mean   : 93.5  
##                     3rd Qu.:39.5   3rd Qu.:143   3rd Qu.: 61.0  
##                     Max.   :45.9   Max.   :146   Max.   :608.8  
##                                                                 
##       mag         magType               nst           gap       
##  Min.   :6.00   Length:732         Min.   :  0   Min.   :  9.0  
##  1st Qu.:6.20   Class :character   1st Qu.:  0   1st Qu.: 15.6  
##  Median :6.60   Mode  :character   Median :251   Median : 23.1  
##  Mean   :6.61                      Mean   :276   Mean   : 32.0  
##  3rd Qu.:6.90                      3rd Qu.:477   3rd Qu.: 37.0  
##  Max.   :9.00                      Max.   :999   Max.   :169.2  
##                                    NA's   :11    NA's   :590    
##       dmin          rms          net                 id           
##  Min.   :0.7   Min.   :0.5   Length:732         Length:732        
##  1st Qu.:1.8   1st Qu.:0.8   Class :character   Class :character  
##  Median :2.7   Median :0.9   Mode  :character   Mode  :character  
##  Mean   :2.9   Mean   :0.9                                        
##  3rd Qu.:3.3   3rd Qu.:1.0                                        
##  Max.   :9.0   Max.   :1.5                                        
##  NA's   :719   NA's   :590                                        
##    updated             place               type          
##  Length:732         Length:732         Length:732        
##  Class :character   Class :character   Class :character  
##  Mode  :character   Mode  :character   Mode  :character  
##                                                          
##                                                          
##                                                          
##                                                          
##      jst.h                         jst.d           
##  Min.   :1900-04-25 08:16:00   Min.   :1900-04-25  
##  1st Qu.:1936-07-30 18:37:29   1st Qu.:1936-07-30  
##  Median :1977-12-22 20:01:23   Median :1977-12-22  
##  Mean   :1969-01-13 04:45:35   Mean   :1969-01-12  
##  3rd Qu.:2003-09-27 19:07:59   3rd Qu.:2003-09-27  
##  Max.   :2014-08-10 12:43:17   Max.   :2014-08-10  
## 
nrow(dataset)
## [1] 8485
nrow(dataset.j)
## [1] 732
sum(all.date[,2])
## [1] 8485
sum(all.date.j[,2])
## [1] 732
head(dataset,1)
##                       time latitude longitude depth mag magType nst gap
## 1 1900-01-05T19:00:00.000Z       -3       102     0   7      ms   0  NA
##   dmin rms        net                       id                  updated
## 1   NA  NA centennial centennial19000105190000 2013-07-09T19:07:15.000Z
##                         place       type               jst.h      jst.d
## 1 southern Sumatra, Indonesia earthquake 1900-01-06 04:00:00 1900-01-06
tail(dataset,1)
##                          time latitude longitude depth mag magType nst gap
## 8485 2014-09-25T17:51:17.000Z    61.95    -151.8 102.8 6.2      ml  NA  NA
##      dmin  rms net         id                  updated
## 8485   NA 0.95  ak ak11401855 2014-09-26T08:10:51.851Z
##                           place       type               jst.h      jst.d
## 8485 94km WNW of Willow, Alaska earthquake 2014-09-26 02:51:17 2014-09-26
head(dataset.j,1)
##                       time latitude longitude depth mag magType nst gap
## 6 1900-04-24T23:16:00.000Z       27     126.5    35 6.9      ms   0  NA
##   dmin rms        net                       id                  updated
## 6   NA  NA centennial centennial19000424231600 2013-07-09T19:07:15.000Z
##                                    place       type               jst.h
## 6 northwest of the Ryukyu Islands, Japan earthquake 1900-04-25 08:16:00
##        jst.d
## 6 1900-04-25
tail(dataset.j,1)
##                          time latitude longitude depth mag magType nst gap
## 8474 2014-08-10T03:43:17.240Z    41.16     142.1    41 6.1     mww  NA  24
##       dmin rms net         id                  updated
## 8474 2.978 0.7  us usb000s1nc 2014-09-19T22:41:39.053Z
##                       place       type               jst.h      jst.d
## 8474 78km E of Mutsu, Japan earthquake 2014-08-10 12:43:17 2014-08-10
head(all.date,1)
##         date NumberOfEarthquake
## 1 1900-01-01                  4
tail(all.date,1)
##            date NumberOfEarthquake
## 1378 2014-10-01                  0
head(all.date.j,1)
##         date NumberOfEarthquake
## 1 1900-01-01                  0
tail(all.date.j,1)
##            date NumberOfEarthquake
## 1378 2014-10-01                  0