Skip to content

Instantly share code, notes, and snippets.

@martinmodrak
Last active January 12, 2022 14:02
Show Gist options
  • Save martinmodrak/0391feb2a62448de5ec38690381f293f to your computer and use it in GitHub Desktop.
Save martinmodrak/0391feb2a62448de5ec38690381f293f to your computer and use it in GitHub Desktop.
library(tidyverse)
library(lubridate)
quakes_raw <- read_csv("https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.csv")
quakes <- quakes_raw %>% mutate(hour = floor_date(time, "hour"),
day = floor_date(time, "day"))
quake_fanos <- quakes %>% group_by(hour, day, net) %>%
summarise(count = n()) %>%
group_by(day, net) %>%
summarise(fano = var(count) / mean(count)) %>%
filter(!is.na(fano))
max_fano <- max(quake_fanos$fano)
quake_fanos %>%
ggplot(aes(x = fano)) + geom_histogram(breaks = seq(0, max_fano, by = 0.5)) +
geom_vline(xintercept = 1, color = "blue", size = 1) +
facet_wrap(~net)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment