Description Usage Arguments Examples
Bake donuts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | bake_donuts(
x,
var,
totals = NULL,
text = list(legend_title = "Region", legend_other = "Other region", legend_stay =
"Home region", popup_residents = "Residents", popup_stay = "Staying", popup_other =
" to other regions", popup_inflow = "From other regions",
popup_outflow = "Leaving", popup_to = " ", edge_to = "to",
edge_flow = "Flow"),
groupname = "Data",
highlight = NULL,
pal = c("blue", "grey70"),
donut_size_min = NA,
donut_size_max = NA,
donut_scale = 1.5,
flow_th = NA,
flow_max = NA,
flow_buffer = NA,
flow_scale = 10,
round_to = 1,
edge_incoming = TRUE,
popup_perc_totals = TRUE,
popup_perc_items = FALSE,
groups = list(),
mute = NULL,
legend = TRUE,
group_label_show = FALSE,
group_label_cex = 1,
group_trunc_m = 2000,
border = NULL,
tm = NULL,
title = NULL,
basemaps = c("Esri.WorldGrayCanvas", "OpenStreetMap")
)
|
x |
|
var |
name of the variable in x$E that contain the flow values |
totals |
total numbers of units per origin. If |
text |
list of text labels in the visualization. See default function call for required list items. |
groupname |
Name of the group what will appear as layer in the interactive map. |
highlight |
Name(s) of the regions (origins or destinations) that will have a distinct color |
pal |
color palette. It should have the length of |
donut_size_min, donut_size_max, donut_scale |
The values that determine the donut size (totals of |
flow_th, |
Only flows of at least |
flow_max, flow_buffer, flow_scale |
The values that determine the flows (specified with |
round_to |
Rounding of the numbers of |
edge_incoming |
Should the edges to drawn from midpoint to destination (so incoming), by default |
popup_perc_totals |
Should percentages be shown for totals in the popups? |
popup_perc_items |
Should percentages be shown for the highlighted regions in the popups? |
groups |
List of groups that specify grouping of nodes. Each item is a list that contains information for one group. The items should be: |
mute |
List that specifies which codes are not shown. The items should be |
legend |
Should the legend be shown? |
group_label_show |
Should the group labels be printed in the map? |
group_label_cex |
Text size of the group labels (in case |
group_trunc_m |
not used |
border |
|
tm |
|
title |
|
basemaps |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | library(odf)
library(donutmaps)
library(tmap)
data("NL_commuting")
data("NL_muni_point")
# Create odf object
x = od(NL_commuting, NL_muni_point, col_orig = "muni_from", col_dest = "muni_to", col_id = "id")
# Define color palette
CBS_pal = c("#d9328a", "#7d4791", "#da5914", "#53a31d", "#0581a2", "#B3B3B3")
# Bake tasty donuts (all commuting traffic)
# Edges are incoming by default
tm = bake_donuts(x,
var = "value",
groupname = "Netherlands",
highlight = c("Amsterdam", "Rotterdam", "Den Haag", "Utrecht"),
pal = CBS_pal,
donut_size_min = 30000, donut_size_max = 400000,
flow_th = 500, flow_max = 20000, flow_buffer = 500, flow_scale = 10,
donut_scale = 1.75)
# The result is a tmap object, which can best be shown in "view mode"
tmap_mode("view")
tm
# Focus on outgoing edges
tm_out = bake_donuts(x,
var = "value",
groupname = "Netherlands",
highlight = c("Amsterdam", "Rotterdam", "Den Haag", "Utrecht"),
pal = CBS_pal,
donut_size_min = 30000, donut_size_max = 400000,
edge_incoming = FALSE,
flow_th = 500, flow_max = 20000, flow_buffer = 500, flow_scale = 10,
donut_scale = 1.75)
tm_out
# Only commute by train
x_train = x
x_train$E = x_train$E[x_train$E$mode == "train", ]
tm_train = bake_donuts(x_train,
var = "value",
groupname = "Netherlands",
highlight = c("Amsterdam", "Rotterdam", "Den Haag", "Utrecht"),
pal = CBS_pal,
donut_size_min = 1000, donut_size_max = 20000,
flow_th = 100, flow_max = 2000, flow_buffer = 100, flow_scale = 15,
donut_scale = 1.75)
tm_train
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.