Chapter 2 eq_location_clean

2.1 Introduction

This function creates a new column with the earthquake LOCATION. The function eq_clean_data uses it behind the scenes, so it is not necessary to call this function after call eq_clean_data.

2.2 Example

Piping a raw data to creates a LOCATION column.

# 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())

# Printing some columns.
df %>%
       eq_location_clean() %>%
              # Selecting some features.
              select(YEAR,
                     COUNTRY,
                     LOCATION,
                     EQ_PRIMARY,
                     TOTAL_DEATHS) %>% 
                     # Filtering.
                     filter(YEAR > 1990 &
                            YEAR < 2019) %>%
                            # Show the first 10 rows.
                            head(10) %>%
                                   # Enhance table visualization.
                                   kable()
YEAR COUNTRY LOCATION EQ_PRIMARY TOTAL_DEATHS
1991 MYANMAR (BURMA) Thabeikkyin, Mandalay 7.1 NA
1991 AFGHANISTAN Badakhstan, Baghlan, Laghman, Nagarhar 6.4 848
1991 SOLOMON ISLANDS Solomon Islands 6.9 NA
1991 FRANCE France 3.8 9
1991 RUSSIA Kuril Islands 5.7 NA
1991 BERING SEA Bering Sea 6.7 NA
1991 CHINA Kalpin 6.1 NA
1991 CHINA Ne, Datong 5.5 NA
1991 PERU Rioja, Neuva Cajamarca 6.4 NA
1991 PERU Rioja, Moyobamba, Nueva Cajamarca 6.7 53

As you can see, the LOCATION column has only cities in Title Case mode.