Mapping data with TERR and leaflet
If your data has location columns (latitude and longitude), you can retrieve data using the dplyr package, and then create a map chart using the TERR-compatible, Javascript-enabled leaflet package.
About this task
The dplyr package is used to filter the original data, and the pipe
operator (%>%
) is used to avoid creating intermediate data
objects.
Tip: If you
search the internet, you can find several informative articles and samples for
the packages we use in this example.
Package link | Package short description |
---|---|
https://dplyr.tidyverse.org/ | Work with data frame-like objects, both in memory and out of memory. |
https://rstudio.github.io/leaflet/ | Create and customize interactive maps using the Leaflet JavaScript library. |
Before you begin
Procedure
Results
zoom
property of the map is set to the specified value.
Each Starbucks store in the Seattle area is indicated by a blue marker. If you
click a marker, the value of the
Name
column is displayed in a pop-up window.
What to do next
Tip: You can
create
create
a formatted HTML document with graphed data using the rmarkdown package.
Parent topic: JavaScript-Enabled Packages