#' Create a Leaflet map widget for earthquakes with location, magnitue and number of deaths
#'
#' This function takes a filtered data frame and maps the epicenters and annotates each point with a pop up window of location, magnitude and number of deaths
#'
#' @param Data A cleaned NOAA data frame
#'
#' @return eq_create_label returns a data frame of text to be displayed in pop up windows when used with eq_map.
#'
#' @importFrom dplyr do
#' @importFrom dplyr mutate
#' @importFrom dplyr rowwise
#' @importFrom magrittr "%>%"
#'
#' @examples
#' \dontrun{
#' Countries <- c('USA', 'CHINA')
#' XMin <- lubridate::ymd('2000-01-01')
#' readr::read_delim(system.file("extdata", "signif.txt", package = "TheCapstoneProject"), delim = '\t') %>%
#' eq_clean_data() %>%
#' eq_location_clean() %>%
#' dplyr::filter(COUNTRY %in% Countries) %>%
#' dplyr::filter(DATE >= XMin) %>%
#' dplyr::mutate(popup_text = eq_create_label(.)) %>%
#' eq_map(Text4Popup = "popup_text")
#' }
#'
#' @export
eq_create_label <- function(Data)
{
Data %>%
dplyr::mutate(location = ifelse(is.na(LOCATION), '', paste("<b>Location:</b>", LOCATION, "<br>")), magnitude = ifelse(is.na(EQ_PRIMARY), '', paste("<b>Magnitude:</b>", EQ_PRIMARY, "<br>")), deaths = ifelse(is.na(DEATHS), '', paste("<b>Total deaths:</b>", DEATHS))) %>%
dplyr::rowwise() %>%
dplyr::do(popup_text = paste(.$location, .$magnitude, .$death)) %>%
unlist(recursive = FALSE) %>%
as.character
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.