R/week1.R

Defines functions eq_clean_data eq_location_clean

# Required Packages -------------------------------------------------------
library(tidyverse) # Data Wrangling


# Data Wrangling Section --------------------------------------------------

# This function merge dates information and change the latitude and longitude to numeric
eq_clean_data <- function(rawData){
  readr::read_delim(rawData, delim = "\t") %>% 
    mutate(dates = lubridate::dmy(paste0(DAY,"-", MONTH,"-", YEAR))) %>% 
    mutate(LATITUDE = as.numeric(LATITUDE),
           LONGITUDE = as.numeric(LONGITUDE))
}


# This function cleans out the Location Name character so it only shows the city or locations
eq_location_clean <- function(rawData){
  
  rawData %>% 
  dplyr::mutate(LOCATION_NAME = LOCATION_NAME %>%
           stringr::str_replace(paste0(COUNTRY, ":"), "") %>%
           stringr::str_trim("both") %>%
           stringr::str_to_title())
  
}
aziizsut/earthquakeVizCap documentation built on Nov. 9, 2019, 12:42 a.m.