knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(magrittr) library(dplyr) library(readr) library(kableExtra) library(msdr)
This function plots circles on OpenStreetMaps, which represents earthquakes. When you click in it appaers a popup, which shows a single information (that you define as annot_col
).
Plotting circles and popup Date of earthquake.
# Path to the raw data. raw_data_path <- system.file("extdata", "signif.txt", package = "msdr") # Loading the dataset of Earthquake. df <- readr::read_delim(file = raw_data_path, delim = '\t', col_names = TRUE, progress = FALSE, col_types = readr::cols()) # Ploting all earthquakes from 1500 to 1700. df %>% # Converting data, cleaning and creating. eq_clean_data() %>% #Filtering. filter(YEAR > 1500 & YEAR < 1700) %>% # Adding circles and popups. eq_map(annot_col = 'DATE')
The popups shows the DATE
when you click the circle.
Popup showing the Location of earthquake.
# Ploting all earthquakes from 1500 to 1700. df %>% # Converting data, cleaning and creating. eq_clean_data() %>% #Filtering. filter(YEAR > 1000 & YEAR < 2019, COUNTRY %in% 'CHILE') %>% # Adding circles and popups. eq_map(annot_col = 'LOCATION')
In this example I have selected the earthquakes in Chile. The function has autozoom to fit the circles in the view.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.