knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
This vignette will demonstrate the use of the timelineR package. It is an extension of the ggplot2 package, dedicated to the plotting of timeline data.It also includes dedicated download and ceaning functions for the NOAA database of hurricanes.
download_sed() downloads the NOAA database of hurricanes as a data frame.
all_hurricanes <- download_sed() head(str(all_hurricanes))
eq_clean_data() cleans the NOAA data frame by converting the LATTITUDE and LONGITUDE columns to integers, and creates a dedicated DATE column.
all_hurricanes_clean <- eq_clean_data(all_hurricanes) str(all_hurricanes_clean)
eq_location_clean() cleans the Location column of the NOAA data frame.
final_hurricanes <- eq_location_clean(all_hurricanes_clean) str(final_hurricanes)
geom_timeline() creates a ggplot object that plots instances of an event over time.
usa_hurricanes <- final_hurricanes%>%filter(COUNTRY == "USA") ggplot(data = usa_hurricanes, aes(DATE, COUNTRY)) + geom_timeline(aes(xmin =as.Date("1990-01-01")))
geom_timeline_label() generates labels for the plotted event instances.
ggplot(data = usa_hurricanes, aes(DATE, COUNTRY)) + geom_timeline(aes(xmin =as.Date("1990-01-01"))) + geom_timeline_label(aes(xmin =as.Date("1990-01-01"), label = LOCATION_NAME))
eq_map() generates a leaflet map of locations of the NOAA hurricanes.
eq_map(usa_hurricanes, annot_col = 'DATE')
eq_create_label() generates an annotation column in the NOAA data frame for use within the leaflet map.
usa_hurricanes%>%eq_create_label(.)%>%eq_map(annot_col = 'popup_text')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.