flowmapblue {flowmapblue} | R Documentation |
Create an interactive flow map
Description
Creates an interactive flow map visualizing flows between various locations and outputs it as an HTML widget. This function utilizes the FlowmapBlue
library to create maps with customizable options such as clustering, animation, and dark mode. The widget can be rendered in R Markdown, Shiny, or viewed in a browser. It can also be saved to html
file with htmlwidgets:saveWidget()
. See examples for more details.
Usage
flowmapblue(
locations,
flows,
mapboxAccessToken = NULL,
clustering = TRUE,
animation = FALSE,
darkMode = FALSE
)
Arguments
locations |
A
|
flows |
A
|
mapboxAccessToken |
A |
clustering |
A |
animation |
A |
darkMode |
A |
Value
An HTML widget of class flowmapblue
and htmlwidget
that can be rendered in R Markdown, Shiny, or viewed in a browser. It can also be saved to html
file with htmlwidgets:saveWidget()
. See examples for more details.
Examples
## Not run:
# example 1, normal flows
# set your Mapbox access token
Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN")
# load locations and flows for Switzerland
locations <- data(ch_locations)
flows <- data(ch_flows)
flowmap <- flowmapblue(
locations,
flows,
mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'),
clustering = TRUE,
darkMode = TRUE,
animation = FALSE
)
# view the map
flowmap
# or save it as an HTML file
htmlwidgets::saveWidget(flowmap, file = "flowmap.html")
# example 2, flows with date in time column
# set your Mapbox access token
Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN")
# load locations and flows for Switzerland
locations <- data(ch_locations)
flows <- data(ch_flows)
# generate fake datetime
flows$time <- seq(from =as.POSIXct("2020-01-01"),
to = as.POSIXct("2020-01-05"), length.out = nrow(flows))
flowmap <- flowmapblue(
locations,
flows,
mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'),
clustering = TRUE,
darkMode = TRUE,
animation = FALSE
)
# view the map
flowmap
# example 3, flows with date in time column
# set your Mapbox access token
Sys.setenv(MAPBOX_API_TOKEN = "YOUR_MAPBOX_ACCESS_TOKEN")
# load locations and flows for Switzerland
locations <- data(ch_locations)
flows <- data(ch_flows)
# generate fake dates
flows$time <- seq(from = as.Date("2020-01-01"),
to = as.Date("2020-06-01"), length.out = nrow(flows))
flowmap <- flowmapblue(
locations,
flows,
mapboxAccessToken = Sys.getenv('MAPBOX_API_TOKEN'),
clustering = TRUE,
darkMode = TRUE,
animation = FALSE
)
# view the map
flowmap
## End(Not run)