![]() Looking at this chart, you can tell that Africa has roughly the same number of countries as Europe, and that most countries are… countries. collapsibleTreeSummary serves as a convenience function around collapsibleTree. We can create a new column in the source data frame for the total number of countries on each continent, and map that column to the fill gradient of the nodes. Let’s use some dplyr to help us with the data aggregation and use colorspace to make some nice looking palettes. Throw in some gradients if you’d like! Each node can have its own distinct color. # Part of the Kingdom of the Netherlands: 6 ![]() # United States Minor Outlying Island : 8 # North America :44 Country - One Main Island: 10 ![]() ![]() # Australia / Oceania:38 Archipelago : 17 # Antarctica : 4 Country - Archipelago : 20 # Aland Islands : 1 Europe :67 Western Asia : 17 # Akrotiri and Dhekelia: 1 Asia :58 Western Africa : 17 # Ajaria : 1 Antarctic: 4 Southern Europe: 17 # Afghanistan : 1 Americas :60 Eastern Africa : 17 Here is an example geography dataset from data.world: summary(Geography) # country region sub_region I’m a big fan of tidy data, but this structure does not lend itself to easily designing hierarchical networks.ĬollapsibleTree uses ee to handle all of that, freeing you from a lot of recursive list construction. When working with data in R, it makes sense (at least to me) to represent everything as a data frame.
0 Comments
Leave a Reply. |