This is an R package for the Coursera course Mastering Software Development in R Capstone.
It consists of four components:
Full documentation, including a vignette, and unit tests are included.
# install.packages("devtools")
devtools::install_github("davidbody/earthquakes-package")
See the vignette for complete details.
library(earthquakes)
library(dplyr)
filename <- system.file("extdata", "earthquakes.tsv.gz", package = "earthquakes")
earthquakes <- readr::read_delim(filename, delim = "\t")
clean_earthquakes <- earthquakes %>%
eq_clean_data()
library(ggplot2)
recent_earthquakes <- clean_earthquakes %>%
filter(COUNTRY == "CANADA" | COUNTRY == "USA", YEAR >= 1980)
g <- ggplot(recent_earthquakes,
aes(x = DATE, y = COUNTRY, size = EQ_PRIMARY, color = TOTAL_DEATHS))
g <- g + geom_timeline(alpha = 0.5)
g <- g + geom_timeline_label(aes(label = LOCATION_NAME, n_max = 3))
g <- g + theme_classic()
g <- g + theme(legend.position = "bottom",
axis.line.y = element_blank(),
axis.ticks.y = element_blank(),
axis.title.y = element_blank())
g <- g + guides(color = guide_colorbar(title = "# deaths"),
size = guide_legend("Richter scale value"))
g
clean_earthquakes %>%
filter(COUNTRY == "MEXICO" & lubridate::year(DATE) >= 2000) %>%
dplyr::mutate(popup_text = eq_create_label(.)) %>%
eq_map(annot_col = "popup_text")
This is a static image. The actual map will be interactive.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.