This vignette two process: - Cleaning - Two different visualizations (over time - like Doctor Who would see it - and country)
About the NOAA earthquake data. the data come can be obtained from NOAA Significant Earthquake Database.
There are ten functions within the package:
fecha()eq_clean_data()eq_location_clean()theme_timeline()GeomTimeline()GeomTimelineLabel()theme_timeline()geom_timeline()geom_timeline_label()eq_map()But only the following functions are exported:
fecha()eq_clean_data()eq_location_clean()theme_timeline()GeomTimeline()GeomTimelineLabel()theme_timeline()eq_map()The package contains the dataset obtained from National Geophysical Data Center / World Data Service (NGDC/WDS): Significant Earthquake Database. National Geophysical Data Center, data. doi:10.7289/V5TD9V7K consulted on the date “12 January, 2018” and and obviously the dataset is called data
filename <- system.file("extdata/signif.txt", package = "FooR")
data <- readr::read_tsv(filename)
data <- eq_clean_data(data)| I_D | FLAG_TSUNAMI | YEAR | MONTH | DAY | HOUR | MINUTE | SECOND |
|---|---|---|---|---|---|---|---|
| 1 | NA | -2150 | NA | NA | NA | NA | |
| 3 | NA | -2000 | NA | NA | NA | NA | NA |
| FOCAL_DEPTH | EQ_PRIMARY | EQ_MAG_MW | EQ_MAG_MS | EQ_MAG_MB | EQ_MAG_ML |
|---|---|---|---|---|---|
| NA | 7.3 | NA | NA | NA | NA |
18 7.1 NA 7.1 NA NA
| EQ_MAG_MFA | EQ_MAG_UNK | INTENSITY | COUNTRY | STATE |
|---|---|---|---|---|
| NA | 7.3 | NA | JORDAN | NA |
| NA | NA | 10 | TURKMENISTAN | NA |
| LOCATION_NAME |
|---|
| JORDAN: BAB-A-DARAA,AL-KARAK |
| TURKMENISTAN: W |
It is evident that the data set has numerous columns with null or missing values, although a future and interesting work for this package would be to apply data imputation techniques to the dataset . For the above you can use the function eq_clean_data() and eq_location_clean()
geom_, geom_timeline and geom_timeline_label. (you must pay attention with the column so that the visualization is of a suitable size and not empty, as in every ggplot´s function, one must have congruent with the variables’ name of the dataset and the parameters of ggplot2::aes function.)1data %>%
filter( DEATHS>0) %>%
ggplot(aes(x = Date,
y = COUNTRY,
color = DEATHS,
size = as.numeric(EQ_PRIMARY)
)) +
geom_timeline() +
#geom_timeline_label(aes(label = LOCATION_NAME)) +
theme_timeline() +
labs(size = "Richter scale value", color = "# deaths",
title = "Figure 1 : Doctor Who's view")COUNTRY or many others, (you must pay attention with the columns of YEAR and DEATHS so that the visualization is of a suitable size and not empty, as in every ggplot´s function, one must have congruent with the variables’ name of the dataset and the parameters of ggplot2::aes function.)data %>%
filter(COUNTRY %in% c("USA"), 2020 > YEAR, YEAR > 2000, DEATHS>0) %>%
ggplot(aes(x = Date,
y = COUNTRY,
color = DEATHS,
size = as.numeric(EQ_PRIMARY)
)) +
geom_timeline() +
geom_timeline_label(aes(label = LOCATION_NAME)) +
theme_timeline() +
labs(size = "Richter scale value", color = "# deaths",
title = "Figure 2: Human vision")data %>%
filter(COUNTRY %in% c("USA", "MEXICO", "JAPAN"), 2020 > YEAR, YEAR > 2000, DEATHS>0) %>%
ggplot(aes(x = Date,
y = COUNTRY,
color = DEATHS,
size = as.numeric(EQ_PRIMARY)
)) +
geom_timeline() +
geom_timeline_label(aes(label = LOCATION_NAME)) +
theme_timeline() +
labs(size = "Richter scale value", color = "# deaths",
title = "Figure 3: Human vision")Using the leaflet package it is very easy to make beautiful interactive maps using the function eq_map().There are two options to use this function one without using the function eq_create_label() from where we get the following map:
data %>%
dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(Date) >= 2000) %>%
eq_map(annot_col = "Date")And the other one using it
data %>%
dplyr::filter(COUNTRY == "MEXICO" & lubridate::year(Date) >= 2000) %>%
dplyr::mutate(popup_text = eq_create_label(.)) %>%
eq_map(annot_col = "popup_text")