create_agg_tree | R Documentation |
Creates a hierarchical data.tree object that defines how different levels of categorical or interval data are related to each other.
create_agg_tree(mapping, exists, col_type)
create_scale_tree(mapping, exists, col_type, collapse_missing = FALSE)
vis_tree(tree)
mapping |
[ |
exists |
[ |
col_type |
[ |
collapse_missing |
[ |
tree |
[ |
Hierarchical tree data structures are used to represent different levels of the categorical or interval data. The r package data.tree is used to implement these data structures.
When vis_tree()
is used to visualize a tree returned by create_agg_tree()
then nodes with data directly provided are colored green, nodes where
aggregation is possible are colored blue, and missing nodes without data
directly provided and where aggregation is impossible because of the missing
nodes are colored red.
When vis_tree()
is used to visualize a tree returned by
create_scale_tree()
then nodes with data directly provided and that can be
scaled are colored green, nodes with data directly provided but that can not
be scaled are colored blue and nodes without data directly provided
create_agg_tree()
and create_scale_tree()
return a
[data.tree()
] with attributes for whether each node has data available
('exists') and whether aggregation to or scaling of each node is possible
('agg_possible' or 'scale_possible'). For create_scale_tree()
, also
includes a field for whether children of each node can be scaled
('scale_children_possible').
vis_tree()
uses networkD3::diagonalNetwork()
to create 'D3' network
graphs.
# aggregation example where all present day locations exist except for Tehran
locations_present <- iran_mapping[!grepl("[0-9]+", child) &
child != "Tehran", child]
agg_tree <- create_agg_tree(iran_mapping, exists = locations_present,
col_type = "categorical")
vis_tree(agg_tree)
# scaling example where all present day locations exist without collapsing
locations_present <- c(iran_mapping[!grepl("[0-9]+", child), child], "Iran")
scale_tree <- create_scale_tree(iran_mapping,
exists = locations_present,
col_type = "categorical")
vis_tree(scale_tree)
# scaling example where all present day locations exist and collapsing tree
scale_tree <- create_scale_tree(iran_mapping,
exists = locations_present,
col_type = "categorical",
collapse = TRUE)
vis_tree(scale_tree)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.