Creator: wispofvapor

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

quakes=read.csv("https://raw.githubusercontent.com/wispofvapor/Earthquakes/main/Quakes%206%200%204-14-22.csv", header=TRUE)
##dataset
ds1 <- quakes 
##Earthquake Frequency
ds1 %>% 
filter(year>1922)%>%
count(year) %>% 
mutate(freq = n) %>%
hchart("column", hcaes(x = year, y = freq), name = "Total 6.0+ Earthquakes") %>%
  hc_annotations(
              list(
                labels = 
                        list(
                          list(
                              point = list(x = 1925, y=56, xAxis = 0, yAxis=0),
                              text = "Twenties<br/>Avg Quakes Per Year <br/> 46"
                              ),
                          list(
                              point = list(x = 1935, y=68, xAxis = 0, yAxis=0),
                              text = "Thirties<br/>Avg Quakes Per Year <br/> 58"
                              ),
                          list(
                              point = list(x = 1945, y=58, xAxis = 0, yAxis=0),
                              text = "Forties<br/>Avg Quakes Per Year<br/> 48"
                              ),
                          list(
                              point = list(x = 1955, y=205, xAxis = 0, yAxis=0),
                              text = "Fifties <br/> Avg Quakes Per Year <br/> 148"
                              ),
                          list(
                              point = list(x = 1965, y=160, xAxis = 0, yAxis=0),
                              text = "Sixties<br/>Avg Quakes Per Year <br/> 137"
                              ),
                          list(
                              point = list(x = 1975, y=165, xAxis = 0, yAxis=0),
                              text = "Seventies<br/>Avg Quakes Per Year<br/> 109"
                              ),
                          list(
                              point = list(x = 1985, y=175, xAxis = 0, yAxis=0),
                              text = "Eighties<br/>Avg Quakes Per Year<br/> 135"
                              ),
                          list(
                              point = list(x = 1995, y=205, xAxis = 0, yAxis=0),
                              text = "Nineties<br/>Avg Quakes Per Year<br/> 154"
                              ),
                          list(
                              point = list(x = 2005, y=200, xAxis = 0, yAxis=0),
                              text = "Aughts<br/>Avg Quakes Per Year<br/> 160"
                              ),
                          list(
                              point = list(x = 2017, y=210, xAxis = 0, yAxis=0),
                              text = "TwentyTens<br/>Avg Quakes Per Year<br/> 144"
                              )),
                labelOptions = list(
                                  shape = 'rect', align = 'center', justify = TRUE, corp = TRUE,
                                  style = list(fontSize='8px'),
                                  backgroundColor = 'rgba(252, 255, 197, 0.7)',
                                  borderWidth = 1,
                                  padding = 10
                                    )
                )
            )%>%
hc_xAxis(title = list (text = "Year"))%>%
hc_yAxis(title = list (text = "Total Earthquakes 6.0+"))%>%
hc_title(text = "Total 6.0+ Earthquakes Per Year")%>%  
#hc_subtitle(text = "Hiroshima (1 atomic bomb) in 1945 released the equivalent energy of a magnitude 6 earthquake.")%>%
hc_add_theme(hc_theme_ffx())
##Earthquake Magnitude
ds1 %>% 
filter(year>1948)%>%
group_by(year) %>%
summarise(mag_max = max(mag, na.rm = TRUE),max_atom = max(AtomBombs, na.rm = TRUE),.groups="drop")%>%
hchart("bubble", hcaes(x = year, y = mag_max, size = max_atom, color = max_atom), name = "Atom Bombs") %>%
hc_xAxis(title = list (text = "Year"))%>%
hc_yAxis(title = list (text = "Magnitude"))%>%
hc_tooltip(useHTML = TRUE,
           formatter = JS(
             "
             function(){
             outHTML = '<b>' + this.point.x + '</b> <br> Magnitude ' + this.point.y.toFixed(1) + 
             '<br> Energy: Atomic Bombs ' + this.point.z.toLocaleString('en-US', {maximumFractionDigits:0})
             return(outHTML)
             }
             "
           ))%>%
hc_annotations(
              list(
                labels = 
                        list(
                          list(
                              point = list(x = 1952, y=9.5, xAxis = 0, yAxis=0),
                              text = "Russia<br/>Caused Tsunami <br/> 2,366 dead"
                              ),
                          list(
                              point = list(x = 1960, y=9.5, xAxis = 0, yAxis=0),
                              text = "Chile<br/>Largest<br/>Recorded<br/>1,655 dead"
                              ),
                          list(
                              point = list(x = 1964, y=9.2, xAxis = 0, yAxis=0),
                              text = "Alaska <br/> Largest US <br/> 131 dead"
                              ),
                          list(
                              point = list(x = 2004, y=9.1, xAxis = 0, yAxis=0),
                              text = "Sumatra<br/>Deadliest <br/> 227,898 dead"
                              ),
                          list(
                              point = list(x = 2011, y=9.1, xAxis = 0, yAxis=0),
                              text = "Japan<br/>Most Recent 'Big One'<br/> 19,747 dead"
                              )),
                labelOptions = list(
                                  shape = 'connector', align = 'right', justify = FALSE, corp = TRUE,
                                  style = list(fontSize='1.0em', textOutline='2px white')
                                    ) 
                )
            )%>%
hc_title(text = "Largest Earthquake Each Year")%>%
#hc_subtitle(text = "Hiroshima (1 atomic bomb) in 1945 released the equivalent energy of a magnitude 6 earthquake.")%>%
hc_add_theme(hc_theme_ffx())
##Earthquake Energy
ds1 %>%
  group_by(year) %>%
  filter(year>1948)%>%
  mutate(ttl_bombs = sum(AtomBombs)) %>%
  hchart("column", hcaes(x = year, y = ttl_bombs), name = "Atomic Bombs") %>%
  #hc_tooltip(pointFormat = "{point.y:,.0f}")%>%
  hc_tooltip(useHTML = TRUE,
           formatter = JS(
             "
             function(){
             outHTML = '<b>' + this.point.x + '</b> <br> Atom Bombs ' + this.point.y.toLocaleString('en-US', {maximumFractionDigits:0}) 
             return(outHTML)
             }
             "
           ))%>%
  hc_xAxis(title = list (text = "Year"))%>%
  hc_yAxis(title = list (text = "Atomic Bombs"))%>%
  hc_title(text = "Total Energy Release of all 6.0+ Earthquakes Per Year: Energy Equivalent = Atomic Bombs")%>%
  hc_subtitle(text = "Hiroshima (1 atomic bomb) in 1945 released the equivalent energy of a magnitude 6 earthquake.")%>%
  hc_add_theme(hc_theme_ffx())
Thirties <- select(filter(ds1, year >= 1930 & year < 1940), c(year, mag))
Thirties$Thirties <- "Thirties"
Thirties %>%
  select (everything()) %>%
  summarise('Average Thirties' = mean(mag))
##   Average Thirties
## 1         6.655788
Forties <- select(filter(ds1, year >= 1940 & year < 1950), c(year, mag))
Forties$Forties <- "Forties"
Forties %>%
  select (everything()) %>%
  summarise('Average Forties' = mean(mag))
##   Average Forties
## 1        6.771969
Fifties <- select(filter(ds1, year >= 1950 & year < 1960), c(year, mag))
Fifties$Fifties <- "Fifties"
Fifties %>%
  select (everything()) %>%
  summarise('Average Fifties' = mean(mag))
##   Average Fifties
## 1        6.327817
Sixties <- select(filter(ds1, year >= 1960 & year < 1970), c(year, mag))
Sixties$Sixties <- "Sixties"
Sixties %>%
  select (everything()) %>%
  summarise('Average Sixties' = mean(mag))
##   Average Sixties
## 1        6.370263
Seventies <- select(filter(ds1, year >= 1970 & year < 1980), c(year, mag))
Seventies$Seventies <- "Seventies"
Seventies %>%
  select (everything()) %>%
  summarise('Average Seventies' = mean(mag))
##   Average Seventies
## 1          6.382056
Eighties <- select(filter(ds1, year >= 1980 & year < 1990), c(year, mag))
Eighties$Eighties <- "Eighties"
Eighties %>%
  select (everything()) %>%
  summarise('Average Eighties' = mean(mag))
##   Average Eighties
## 1         6.367786
Nineties <- select(filter(ds1, year >= 1990 & year < 2000), c(year, mag))
Nineties$Nineties <- "Nineties"
Nineties %>%
  select (everything()) %>%
  summarise('Average Nineties' = mean(mag))
##   Average Nineties
## 1         6.378601
Aughts <- select(filter(ds1, year >= 2000 & year < 2010), c(year, mag))
Aughts$Aughts <- "Aughts"
Aughts %>%
  select (everything()) %>%
  summarise('Average Aughts' = mean(mag))
##   Average Aughts
## 1       6.363846
TwentyTens <- select(filter(ds1, year >= 2010 & year < 2020), c(year, mag))
TwentyTens$TwentyTens <- "Twenty-Tens"
TwentyTens %>%
  select (everything()) %>%
  summarise('Average Twenty-Tens' = mean(mag))
##   Average Twenty-Tens
## 1            6.392522
ds1 %>%
  filter(year >= 1930 & year < 1940)%>%
  summarise('Avg Quakes Thirties' = mean(mag))
##   Avg Quakes Thirties
## 1            6.655788
decades <- ds1 %>%
group_by(group = cut(year, breaks = seq(0, max(year),10), dig.lab = 4)) %>%
summarise(n = n())%>%
  mutate(Frequakes = n/10)