2014年9月17日:過去30日間に発生した地震に関する各種ヒストグラム-世界全体および日本の状況について

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

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

Read Data

dataset<-read.csv("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv")

Part of Data

head(dataset,5)
##                       time latitude longitude depth  mag magType nst   gap
## 1 2014-09-17T10:06:12.800Z    47.56    -122.9 13.50 4.00      Ml  NA  57.6
## 2 2014-09-17T10:04:24.300Z    19.26    -155.1 46.20 2.10      Md  NA 208.8
## 3 2014-09-17T09:59:55.050Z    38.83    -122.8  2.93 1.15      md  23  41.0
## 4 2014-09-17T09:58:50.970Z    33.03    -116.0  3.47 1.01      ml  19 120.0
## 5 2014-09-17T09:48:48.900Z    34.31    -117.0 34.48 1.42      ml   8 336.0
##       dmin  rms net         id                  updated
## 1 0.080848 0.25  uw uw60881241 2014-09-17T10:14:38.060Z
## 2 0.071865 0.16  hv hv60773181 2014-09-17T10:07:51.424Z
## 3 0.004124 0.02  nc nc72300791 2014-09-17T10:16:09.967Z
## 4 0.141100 0.25  ci ci37268984 2014-09-17T10:02:38.010Z
## 5 0.499700 0.18  ci ci37268976 2014-09-17T09:52:44.050Z
##                                 place       type
## 1      12km SW of Seabeck, Washington earthquake
## 2          26km SE of Volcano, Hawaii earthquake
## 3   8km NW of The Geysers, California earthquake
## 4   30km S of Salton City, California earthquake
## 5 9km NW of Big Bear Lake, California earthquake

Number of Earthquakes in the past 30days by Magnitude

  • Ratio(%)=Japan/World*100
region<-c("","Japan","Indonesia","Mexico","Alaska")
mgt<-c(0,1,2.5,4.5,5.5)
Ecount<-matrix(nrow=length(mgt),ncol=length(region))
for(rrr in 1:length(region)){
r.dataset<-dataset[grep(region[rrr],dataset[,14]),]
for(mmm in 1:length(mgt)){
count<-length(subset(r.dataset,mgt[mmm]<=r.dataset[,5])[,1])
Ecount[mmm,rrr]<-count
}
}
Ecount<-as.data.frame(Ecount)
rownames(Ecount)<-paste("over",mgt,sep="")
rownames(Ecount)[1]<-"All"
colnames(Ecount)<-region
colnames(Ecount)[1]<-"World"
Ratio<-signif(Ecount$Japan/Ecount$World*100,digits=2)
Ecount<-cbind(Ecount,Ratio)
Ecount<-Ecount[,c(1,2,6,3,4,5)]
kable(Ecount)
WorldJapanRatioIndonesiaMexicoAlaska
All9020430.4858683659
over16034430.7158682636
over2.51265433.405833292
over4.5392348.70451111
over5.53326.10410

Histogram

bw=c(5,5,10,0.1)
for(rrr in 1:length(region)){
r.dataset<-dataset[grep(region[rrr],dataset[,14]),]
if(rrr==1){PlotTitle<-"World"}else{PlotTitle<-region[rrr]}
for(ppp in 1:4){ 
switch(ppp,
g<-ggplot(r.dataset,aes(x=latitude)),
g<-ggplot(r.dataset,aes(x=longitude)),
g<-ggplot(r.dataset,aes(x=depth)),
g<-ggplot(r.dataset,aes(x=mag))
)  
g<-g+geom_histogram(alpha=0.2,binwidth=bw[ppp],colour="blue")
g<-g+labs(title=PlotTitle)
g<-g+theme(axis.title.x=element_text(size=9),axis.title.y=element_text(size=9)) 
g<-g+theme(axis.text.x=element_text(size=9),axis.text.y=element_text(size=9)) 
switch(ppp,
lat<-g,
lon<-g,
dep<-g,
magn<-g
)
}
grid.arrange(lat,lon,dep,magn,nrow=1,ncol=4)
}

plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5