#' Add a LOCATION column
#'
#' This function takes a NOAA data frame and adds a LOCATION column from LOCATION_NAME
#'
#' @param Data A raw NOAA data frame
#'
#' @return eq_location_clean returns a data frame with a LOCATION column.
#'
#' @importFrom dplyr mutate
#' @importFrom magrittr "%>%"
#' @importFrom stringr str_split
#' @importFrom stringr str_to_title
#'
#' @examples
#' \dontrun{
#' read_delim(system.file("extdata", "signif.txt", package = "TheCapstoneProject"), delim = '\t') %>%
#' eq_location_clean()
#' }
#'
#' @export
eq_location_clean <- function(Data)
{
Data$LOCATION <- vector(length = nrow(Data))
Data$LOCATION <- sapply(stringr::str_split(Data$LOCATION_NAME, ':', ), '[[', 1)
Data$LOCATION[sapply(stringr::str_split(Data$LOCATION_NAME, ':'), 'length')>1] <- trimws(sapply(stringr::str_split(Data$LOCATION_NAME[sapply(stringr::str_split(Data$LOCATION_NAME, ':'), 'length')>1], ':', ), '[[', 2))
Data$LOCATION <- stringr::str_to_title(Data$LOCATION)
Data
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.