Chapter 8 eq_create_label
This function compounds a new information to be displayed in a popup of Leaflet package. For this reason, the dataset should have LOCATION
, EQ_PRIMARY
and DATE
.
8.1 Example 1
The next example only show the content of each popup of Leaflet map.
# 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())
# Display the informaiton of each popup.
df %>% eq_create_label() %>% head() %>% kable()
x |
---|
<b>Location: </b><br><b>Magnitude: </b> 7.3<br><b>Total deaths: </b>NA |
<b>Location: </b><br><b>Magnitude: </b> 7.1<br><b>Total deaths: </b> 1 |
<b>Location: </b><br><b>Magnitude: </b>NA<br><b>Total deaths: </b>NA |
<b>Location: </b><br><b>Magnitude: </b>NA<br><b>Total deaths: </b>NA |
<b>Location: </b><br><b>Magnitude: </b>NA<br><b>Total deaths: </b>NA |
<b>Location: </b><br><b>Magnitude: </b>NA<br><b>Total deaths: </b>NA |
8.2 Example 2
This example shows the complete case of plotting a popup with Location, Magnitude and date.
# Display the informaiton of each popup.
df %>%
# Cleaninig the data.
eq_clean_data() %>%
# Creating new content.
dplyr::mutate(popup_text = eq_create_label(.)) %>%
# Plotting new content inside of popup.
eq_map(annot_col = "popup_text")