Intro Thoughts

w ggraph()

library(tidyverse)
library(tidygraph)
## 
## Attaching package: 'tidygraph'
## The following object is masked from 'package:stats':
## 
##     filter
library(ggraph)

set.seed(9876)
as_tbl_graph(highschool) %>% 
  activate("edges") %>% 
  filter(year == 1957) %>% 
  ggraph() + 
  geom_node_point() + 
  geom_edge_link()
## Using "stress" as default layout

layer_data(i = 2) %>% tibble()
## # A tibble: 24,300 × 20
##    PANEL     x     y group  index edge_colour edge_width edge_linetype
##    <fct> <dbl> <dbl> <chr>  <dbl> <chr>            <dbl> <chr>        
##  1 1      9.64  2.09 1     0      black              0.5 solid        
##  2 1      9.65  2.10 1     0.0101 black              0.5 solid        
##  3 1      9.67  2.10 1     0.0202 black              0.5 solid        
##  4 1      9.68  2.10 1     0.0303 black              0.5 solid        
##  5 1      9.70  2.10 1     0.0404 black              0.5 solid        
##  6 1      9.71  2.10 1     0.0505 black              0.5 solid        
##  7 1      9.73  2.10 1     0.0606 black              0.5 solid        
##  8 1      9.74  2.11 1     0.0707 black              0.5 solid        
##  9 1      9.76  2.11 1     0.0808 black              0.5 solid        
## 10 1      9.78  2.11 1     0.0909 black              0.5 solid        
## # ℹ 24,290 more rows
## # ℹ 12 more variables: edge_alpha <lgl>, start_cap <lgl>, end_cap <lgl>,
## #   label <lgl>, label_pos <dbl>, label_size <dbl>, angle <dbl>, hjust <dbl>,
## #   vjust <dbl>, family <chr>, fontface <dbl>, lineheight <dbl>

preprocessing and piping into ggplot()

set.seed(9876)
as_tbl_graph(highschool) %>%
  activate("edges") %>% 
  tidygraph::as_tibble() %>% 
  filter(year == 1957) ->
edgelist  


edgelist %>% # edgelist
  tidygraph::as_tbl_graph() %>% 
  create_layout(layout = "stress") ->
node_layout

edgelist %>% 
  left_join(node_layout %>% 
              select(from = .ggraph.orig_index, 
                     x, y)) %>% 
  left_join(node_layout %>% 
              select(to = .ggraph.orig_index,
                     xend = x,
                     yend = y)) %>% 
  ggplot() + 
  aes(x = x, y = y) + 
  geom_point() + 
  aes(xend = xend, yend = yend) +
  geom_segment()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`

layer_data()  %>% tibble()  
## # A tibble: 243 × 12
##      xend  yend      x     y PANEL group shape colour  size fill  alpha stroke
##     <dbl> <dbl>  <dbl> <dbl> <fct> <int> <dbl> <chr>  <dbl> <lgl> <lgl>  <dbl>
##  1 11.2   2.27   9.64   2.09 1        -1    19 black    1.5 NA    NA       0.5
##  2 10.3   0.889  9.64   2.09 1        -1    19 black    1.5 NA    NA       0.5
##  3 10.0   2.41   9.64   2.09 1        -1    19 black    1.5 NA    NA       0.5
##  4  8.82  2.89   9.64   2.09 1        -1    19 black    1.5 NA    NA       0.5
##  5  9.27  3.08   9.64   2.09 1        -1    19 black    1.5 NA    NA       0.5
##  6 10.0   2.41  10.8    3.22 1        -1    19 black    1.5 NA    NA       0.5
##  7 10.5   2.13  10.8    3.22 1        -1    19 black    1.5 NA    NA       0.5
##  8 10.0   1.20  10.4    0    1        -1    19 black    1.5 NA    NA       0.5
##  9 10.3   0.889 10.4    0    1        -1    19 black    1.5 NA    NA       0.5
## 10  0.305 3.94   0.770  4.37 1        -1    19 black    1.5 NA    NA       0.5
## # ℹ 233 more rows

trying to make some Stats…

compute_panel_edgelist_nodes <- function(data = edgelist, scales, layout = "stress", seed = 12345){
  
set.seed(seed)
    
node_names <- unique(c(data$from, data$to))

data %>% # edgelist
  select(from, to, everything()) %>% 
  tidygraph::as_tbl_graph() ->
graph    
    
graph %>% 
  ggraph::create_layout(layout = layout) ->
node_layout


node_layout$name <- node_names
node_layout$is_from <- node_names %in% data$from
node_layout$is_to <- node_names %in% data$to
node_layout$is_from_and_to <- node_layout$is_from & node_layout$is_to
node_layout$node_type <- case_when(node_layout$is_from_and_to ~ "both",
                                     node_layout$is_from ~ "from",
                                     node_layout$is_to ~ "to", TRUE ~ "neither")

node_layout
  
}


StatEdgelistNodes <- ggproto("StatEdgelistNodes", 
                        Stat,
                        compute_panel = compute_panel_edgelist_nodes,
                        required_aes = c("from", "to"),
                        default_aes = aes(label = after_stat(name)))


edgelist %>% 
  ggplot() + 
  aes(from = from, to = to) + 
  geom_point(stat = StatEdgelistNodes, color = "grey") + 
  geom_text(stat = StatEdgelistNodes) + 
  aes(size = after_stat(node_type) == "both")
## Warning: Using size for a discrete variable is not advised.

compute_panel_edgelist_edges <- function(data = edgelist, scales, layout = "stress", seed = 12345){
  
  set.seed(seed)
  
data %>% # edgelist
  select(from, to, everything()) %>% 
  tidygraph::as_tbl_graph() %>% 
  ggraph::create_layout(layout = layout) ->
node_layout
  
data %>% 
  select(from, to, everything()) %>% 
  # group_by(PANEL, group) %>% 
  tidygraph::as_tbl_graph() %>% 
  activate("edges") %>% 
  as_tibble() %>% 
  left_join(node_layout %>% 
              select(from = .ggraph.orig_index, 
                     x, y)) %>% 
  left_join(node_layout %>% 
              select(to = .ggraph.orig_index,
                     xend = x,
                     yend = y)) %>% 
   mutate(group = 1, 
          PANEL = 1) %>% 
  mutate(node_type = "both")
  
}

edgelist %>% 
  compute_panel_edgelist_edges()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## # A tibble: 243 × 10
##     from    to  year      x     y   xend  yend group PANEL node_type
##    <int> <int> <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl> <dbl> <chr>    
##  1     1    13  1957  9.64   2.09 11.2   2.27      1     1 both     
##  2     1    14  1957  9.64   2.09 10.3   0.889     1     1 both     
##  3     1    20  1957  9.64   2.09 10.0   2.41      1     1 both     
##  4     1    52  1957  9.64   2.09  8.82  2.89      1     1 both     
##  5     1    53  1957  9.64   2.09  9.27  3.08      1     1 both     
##  6     2    20  1957 10.8    3.22 10.0   2.41      1     1 both     
##  7     2    21  1957 10.8    3.22 10.5   2.13      1     1 both     
##  8     3     9  1957 10.4    0    10.0   1.20      1     1 both     
##  9     3    14  1957 10.4    0    10.3   0.889     1     1 both     
## 10     4     5  1957  0.770  4.37  0.305 3.94      1     1 both     
## # ℹ 233 more rows
StatEdgelistEdges <- ggproto("StatEdgelistEdges", 
                        Stat,
                        compute_panel = compute_panel_edgelist_edges,
                        required_aes = c("from", "to"))

last_plot() + 
  geom_segment(stat = StatEdgelistEdges, size = .5, color = "grey") #uh oh!
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.

layer_data(i = 2) %>% head()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.
##   size label PANEL          x        y circular .ggraph.orig_index
## 1    2     1     1  9.6365178 2.093482    FALSE                  1
## 2    2     2     1 10.7685831 3.220272    FALSE                  2
## 3    2     3     1 10.3913611 0.000000    FALSE                  3
## 4    6     4     1  0.7701130 4.371856    FALSE                  4
## 5    6     5     1  0.3051852 3.936482    FALSE                  5
## 6    6     6     1 11.7324035 1.864297    FALSE                  6
##   .ggraph.index name is_from is_to is_from_and_to node_type colour family angle
## 1             1    1    TRUE FALSE          FALSE      from  black            0
## 2             2    2    TRUE FALSE          FALSE      from  black            0
## 3             3    3    TRUE FALSE          FALSE      from  black            0
## 4             4    4    TRUE  TRUE           TRUE      both  black            0
## 5             5    5    TRUE  TRUE           TRUE      both  black            0
## 6             6    6    TRUE  TRUE           TRUE      both  black            0
##   hjust vjust alpha fontface lineheight
## 1   0.5   0.5    NA        1        1.2
## 2   0.5   0.5    NA        1        1.2
## 3   0.5   0.5    NA        1        1.2
## 4   0.5   0.5    NA        1        1.2
## 5   0.5   0.5    NA        1        1.2
## 6   0.5   0.5    NA        1        1.2
user_repo_fun <- read_csv("https://raw.githubusercontent.com/EvaMaeRey/mytidytuesday/refs/heads/main/2024-11-19-gg-prefixes/exported_funs_exts_ggplot2_tidyverse_org.csv")
## Rows: 5527 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): user, repo, fun_exported
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
user_repo_fun |>
  mutate(prefix_short = fun_exported %>% str_extract(".*?_")) %>% 
  mutate(prefix_long = fun_exported %>% str_extract(".+_")) ->
user_repo_fun_prefix
  
user_repo_fun_prefix |>
  filter(!is.na(prefix_short)) |> 
  filter(n() > 20, .by = prefix_short) |>
  filter(prefix_short != "easy_") |>
  ggplot() +
  aes(from = repo, to = prefix_short) + 
  geom_point(stat = StatEdgelistNodes, color = "grey") + 
  geom_segment(stat = StatEdgelistEdges, color = "grey", size = .2) +
  geom_text(stat = StatEdgelistNodes) + 
  aes(size = after_stat(node_type) == "to") + 
  theme(legend.position = "none") 
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.

last_plot() + 
  aes(from = user)
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.

last_plot() + 
  aes(id = fun_exported %>% str_extract(".+_"))
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.

last_plot()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
## Warning: Using size for a discrete variable is not advised.

cran_20230905 <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-19/cran_20230905.csv')
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)
## Rows: 19838 Columns: 67
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (51): Package, Version, Priority, Depends, Imports, LinkingTo, Suggests...
## lgl  (15): License_is_FOSS, License_restricts_use, BuildKeepEmpty, BuildManu...
## date  (1): Published
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
package_authors <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-19/package_authors.csv')
## Rows: 51281 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): Package, authorsR
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cran_20230905 %>%
  filter(Package %>%
           str_detect("^gg|^GG")) %>%
  filter(Imports %>%
           str_detect("ggplot2")|
         Depends %>% str_detect("ggplot2")) %>%
  select(Package) %>%
  left_join(package_authors %>%
              mutate(authorsR = authorsR %>%
                       str_replace(" ", "\n"))) %>% 
  ggplot() + 
  aes(from = Package, to = authorsR) + 
  geom_point(stat = StatEdgelistNodes) + 
  geom_segment(stat = StatEdgelistEdges)
## Joining with `by = join_by(Package)`
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`

gapminder::gapminder %>% 
  ggplot() + 
  aes(from = continent, to = country) + 
  geom_point(stat = StatEdgelistNodes) + 
  geom_segment(stat = StatEdgelistEdges)
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`

layer_data() %>% head()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
##         label PANEL          x          y circular .ggraph.orig_index
## 1        Asia     1 11.9216781 1.38805633    FALSE                  1
## 2      Europe     1  8.1613728 1.41185069    FALSE                  2
## 3      Africa     1 15.8090130 1.47845457    FALSE                  3
## 4    Americas     1  4.3701744 1.39917414    FALSE                  4
## 5     Oceania     1  0.9995374 0.05483522    FALSE                  5
## 6 Afghanistan     1 12.1840925 2.41220939    FALSE                  6
##   .ggraph.index        name is_from is_to is_from_and_to node_type shape colour
## 1             1        Asia    TRUE FALSE          FALSE      from    19  black
## 2             2      Europe    TRUE FALSE          FALSE      from    19  black
## 3             3      Africa    TRUE FALSE          FALSE      from    19  black
## 4             4    Americas    TRUE FALSE          FALSE      from    19  black
## 5             5     Oceania    TRUE FALSE          FALSE      from    19  black
## 6             6 Afghanistan   FALSE  TRUE          FALSE        to    19  black
##   size fill alpha stroke
## 1  1.5   NA    NA    0.5
## 2  1.5   NA    NA    0.5
## 3  1.5   NA    NA    0.5
## 4  1.5   NA    NA    0.5
## 5  1.5   NA    NA    0.5
## 6  1.5   NA    NA    0.5
gapminder::gapminder %>% 
  ggplot() + 
  aes(from = continent, to = country) + 
  geom_point(stat = StatEdgelistNodes, layout = "circlepack") + 
  geom_segment(stat = StatEdgelistEdges, layout = "circlepack")
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`

layer_data()
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`
##                        label PANEL           x           y         r circular
## 1                       Asia     1 -1.93886330 -6.64720574 3.5496000    FALSE
## 2                     Europe     1 -1.93886329 -6.64720576 0.5641896    FALSE
## 3                     Africa     1 -2.14400192 -7.75678112 0.5641896    FALSE
## 4                   Americas     1 -1.08051212 -7.37964871 0.5641896    FALSE
## 5                    Oceania     1 -3.00235309 -7.02433818 0.5641896    FALSE
## 6                Afghanistan     1 -2.79721444 -5.91476279 0.5641896    FALSE
## 7                    Albania     1 -0.87537351 -6.27007331 0.5641896    FALSE
## 8                    Algeria     1 -1.73372468 -5.53763037 0.5641896    FALSE
## 9                     Angola     1 -2.59207583 -4.80518739 0.5641896    FALSE
## 10                 Argentina     1 -3.20749170 -8.13391357 0.5641896    FALSE
## 11                 Australia     1 -1.28565076 -8.48922410 0.5641896    FALSE
## 12                   Austria     1 -0.01702233 -7.00251626 0.5641896    FALSE
## 13                   Bahrain     1 -0.67023489 -5.16049792 0.5641896    FALSE
## 14                Bangladesh     1 -3.86070424 -6.29189520 0.5641896    FALSE
## 15                   Belgium     1 -2.34914053 -8.86635652 0.5641896    FALSE
## 16                     Benin     1 -1.49078938 -9.59879949 0.5641896    FALSE
## 17                   Bolivia     1 -4.06584287 -7.40147062 0.5641896    FALSE
## 18    Bosnia and Herzegovina     1 -0.22216097 -8.11209168 0.5641896    FALSE
## 19                  Botswana     1 -1.52858607 -4.42805497 0.5641896    FALSE
## 20                    Brazil     1 -3.65556559 -5.18231981 0.5641896    FALSE
## 21                  Bulgaria     1 -4.92419403 -6.66902765 0.5641896    FALSE
## 22              Burkina Faso     1  0.18811628 -5.89294087 0.5641896    FALSE
## 23                   Burundi     1  0.39325489 -4.78336547 0.5641896    FALSE
## 24                  Cambodia     1  0.84132882 -7.73495923 0.5641896    FALSE
## 25                  Cameroon     1 -3.45042698 -4.07274442 0.5641896    FALSE
## 26                    Canada     1 -2.38693722 -3.69561200 0.5641896    FALSE
## 27  Central African Republic     1 -3.41263031 -9.24348897 0.5641896    FALSE
## 28                      Chad     1 -0.42729961 -9.22166707 0.5641896    FALSE
## 29                     Chile     1 -4.27098149 -8.51104602 0.5641896    FALSE
## 30                     China     1 -0.46509628 -4.05092252 0.5641896    FALSE
## 31                  Colombia     1 -4.71905539 -5.55945223 0.5641896    FALSE
## 32                   Comoros     1 -5.08274434  0.90691308 4.6326185    FALSE
## 33          Congo, Dem. Rep.     1 -5.08274433  0.90691311 0.5641896    FALSE
## 34               Congo, Rep.     1 -4.65232422  1.94997489 0.5641896    FALSE
## 35                Costa Rica     1 -5.77085231  1.80119876 0.5641896    FALSE
## 36             Cote d'Ivoire     1 -3.96421625  1.05568924 0.5641896    FALSE
## 37                   Croatia     1 -4.39463638  0.01262744 0.5641896    FALSE
## 38                      Cuba     1 -5.51316447 -0.13614869 0.5641896    FALSE
## 39            Czech Republic     1 -6.20127241  0.75813695 0.5641896    FALSE
## 40                   Denmark     1 -6.63169254 -0.28492485 0.5641896    FALSE
## 41                  Djibouti     1 -3.53379615  2.09875105 0.5641896    FALSE
## 42        Dominican Republic     1 -5.34043217  2.84426056 0.5641896    FALSE
## 43                   Ecuador     1 -3.27610830  0.16140357 0.5641896    FALSE
## 44                     Egypt     1 -4.82505652 -1.03043436 0.5641896    FALSE
## 45               El Salvador     1 -6.88938039  1.65242260 0.5641896    FALSE
## 46         Equatorial Guinea     1 -4.22190412  2.99303670 0.5641896    FALSE
## 47                   Eritrea     1 -4.91001207  3.88732237 0.5641896    FALSE
## 48                  Ethiopia     1 -6.45896026  2.69548443 0.5641896    FALSE
## 49                   Finland     1 -2.84568817  1.20446540 0.5641896    FALSE
## 50                    France     1 -7.57748833  2.54670827 0.5641896    FALSE
## 51                     Gabon     1 -5.94358460 -1.17921049 0.5641896    FALSE
## 52                    Gambia     1 -3.70652843 -0.88165823 0.5641896    FALSE
## 53                   Germany     1 -2.58800035 -0.73288210 0.5641896    FALSE
## 54                     Ghana     1 -2.15758022  0.31017973 0.5641896    FALSE
## 55                    Greece     1 -7.31980049  0.60936078 0.5641896    FALSE
## 56                 Guatemala     1 -7.75022062 -0.43370101 0.5641896    FALSE
## 57                    Guinea     1 -7.06211268 -1.32798665 0.5641896    FALSE
## 58             Guinea-Bissau     1 -3.10337604  3.14181287 0.5641896    FALSE
## 59                     Haiti     1 -6.02854012  3.73854623 0.5641896    FALSE
## 60                  Honduras     1 -2.41526807  2.24752722 0.5641896    FALSE
## 61          Hong Kong, China     1 -4.13694857 -1.92472003 0.5641896    FALSE
## 62                   Hungary     1 -8.00790846  1.50364643 0.5641896    FALSE
## 63                   Iceland     1 -5.25547665 -2.07349616 0.5641896    FALSE
## 64                     India     1 -1.98484797  3.29058903 0.5641896    FALSE
## 65                 Indonesia     1 -5.59812002  4.78160804 0.5641896    FALSE
## 66                      Iran     1 -1.46947227 -0.58410594 0.5641896    FALSE
## 67                      Iraq     1 -8.69601641  2.39793210 0.5641896    FALSE
## 68                   Ireland     1 -4.56736870 -2.96778183 0.5641896    FALSE
## 69                    Israel     1 -8.18064076 -1.47676281 0.5641896    FALSE
## 70                     Italy     1 -3.79148402  4.03609851 0.5641896    FALSE
## 71                   Jamaica     1 -4.47959197  4.93038418 0.5641896    FALSE
## 72                     Japan     1 -7.14706820  3.58977010 0.5641896    FALSE
## 73                    Jordan     1 -1.72716009  1.35324153 0.5641896    FALSE
## 74                     Kenya     1 -1.29673999  2.39630335 0.5641896    FALSE
## 75          Korea, Dem. Rep.     1 -8.26559628  3.44099394 0.5641896    FALSE
## 76               Korea, Rep.     1 -3.01842049 -1.77594390 0.5641896    FALSE
## 77                    Kuwait     1 -1.89989240 -1.62716777 0.5641896    FALSE
## 78                   Lebanon     1 -8.43832856  0.46058462 0.5641896    FALSE
## 79                   Lesotho     1 -6.37400473 -2.22227228 0.5641896    FALSE
## 80                   Liberia     1 -8.86874870 -0.58247718 0.5641896    FALSE
## 81                     Libya     1 -7.49253281 -2.37104845 0.5641896    FALSE
## 82                Madagascar     1 -2.67295594  4.18487468 0.5641896    FALSE
## 83                    Malawi     1 -1.03905214  0.45895586 0.5641896    FALSE
## 84                  Malaysia     1 -6.71664807  4.63283190 0.5641896    FALSE
## 85                      Mali     1  2.78315658 -1.34615217 3.5496000    FALSE
## 86                Mauritania     1  2.78315656 -1.34615217 0.5641896    FALSE
## 87                 Mauritius     1  1.95551368 -2.11312452 0.5641896    FALSE
## 88                    Mexico     1  3.03355269 -2.44639814 0.5641896    FALSE
## 89                  Mongolia     1  1.70511755 -1.01287855 0.5641896    FALSE
## 90                Montenegro     1  2.53276048 -0.24590620 0.5641896    FALSE
## 91                   Morocco     1  3.61079948 -0.57917982 0.5641896    FALSE
## 92                Mozambique     1  3.86119557 -1.67942579 0.5641896    FALSE
## 93                   Myanmar     1  4.11159170 -2.77967176 0.5641896    FALSE
## 94                   Namibia     1  2.20590977 -3.21337050 0.5641896    FALSE
## 95                     Nepal     1  0.87747466 -1.77985095 0.5641896    FALSE
## 96               Netherlands     1  1.45472147  0.08736742 0.5641896    FALSE
## 97               New Zealand     1  3.36040340  0.52106616 0.5641896    FALSE
## 98                 Nicaragua     1  4.68883849 -0.91245344 0.5641896    FALSE
## 99                     Niger     1  1.12787079 -2.88009691 0.5641896    FALSE
## 100                  Nigeria     1  1.37826688 -3.98034289 0.5641896    FALSE
## 101                   Norway     1  0.62707853 -0.67960498 0.5641896    FALSE
## 102                     Oman     1  3.28394877 -3.54664412 0.5641896    FALSE
## 103                 Pakistan     1  2.28236439  0.85433978 0.5641896    FALSE
## 104                   Panama     1  1.20432539  1.18761340 0.5641896    FALSE
## 105                 Paraguay     1  0.37668245  0.42064099 0.5641896    FALSE
## 106                     Peru     1  4.43844241  0.18779254 0.5641896    FALSE
## 107              Philippines     1  4.93923458 -2.01269941 0.5641896    FALSE
## 108                   Poland     1  5.51648142 -0.14548108 0.5641896    FALSE
## 109                 Portugal     1  5.18963071 -3.11294538 0.5641896    FALSE
## 110              Puerto Rico     1  4.36198778 -3.87991774 0.5641896    FALSE
## 111                  Reunion     1 -6.21148593 -4.74242638 1.1283791    FALSE
## 112                  Romania     1 -6.21129546 -4.17823686 0.5641896    FALSE
## 113                   Rwanda     1 -6.21167639 -5.30661590 0.5641896    FALSE
## 114    Sao Tome and Principe     1  1.80202014  6.17805217 4.0383035    FALSE
## 115             Saudi Arabia     1  1.37897452  5.88805493 0.5641896    FALSE
## 116                  Senegal     1  2.30967488  6.52604882 0.5641896    FALSE
## 117                   Serbia     1  1.29180577  7.01306205 0.5641896    FALSE
## 118             Sierra Leone     1  2.39684363  5.40104170 0.5641896    FALSE
## 119                Singapore     1  0.36110540  6.37506813 0.5641896    FALSE
## 120          Slovak Republic     1  0.44827416  5.25006101 0.5641896    FALSE
## 121                 Slovenia     1  1.46614328  4.76304781 0.5641896    FALSE
## 122                  Somalia     1  2.48401239  4.27603459 0.5641896    FALSE
## 123             South Africa     1  3.32754400  6.03903562 0.5641896    FALSE
## 124                    Spain     1  2.22250615  7.65105594 0.5641896    FALSE
## 125                Sri Lanka     1  0.53544291  4.12505390 0.5641896    FALSE
## 126                    Sudan     1  0.27393664  7.50007525 0.5641896    FALSE
## 127                Swaziland     1 -0.56959496  5.73707422 0.5641896    FALSE
## 128                   Sweden     1  3.24037524  7.16404274 0.5641896    FALSE
## 129              Switzerland     1  3.15320651  8.28904986 0.5641896    FALSE
## 130                    Syria     1  1.20463704  8.13806917 0.5641896    FALSE
## 131                   Taiwan     1  3.41471275  4.91402850 0.5641896    FALSE
## 132                 Tanzania     1 -0.65676372  6.86208133 0.5641896    FALSE
## 133                 Thailand     1 -0.48242621  4.61206710 0.5641896    FALSE
## 134                     Togo     1 -0.39525745  3.48705998 0.5641896    FALSE
## 135      Trinidad and Tobago     1  1.55331204  3.63804069 0.5641896    FALSE
## 136                  Tunisia     1  0.18676791  8.62508237 0.5641896    FALSE
## 137                   Turkey     1 -0.74393248  7.98708845 0.5641896    FALSE
## 138                   Uganda     1  2.57118115  3.15102747 0.5641896    FALSE
## 139           United Kingdom     1  3.50188151  3.78902139 0.5641896    FALSE
## 140            United States     1  4.25824436  6.67702954 0.5641896    FALSE
## 141                  Uruguay     1  2.13533742  8.77606306 0.5641896    FALSE
## 142                Venezuela     1  4.34541312  5.55202242 0.5641896    FALSE
## 143                  Vietnam     1  0.62261167  3.00004678 0.5641896    FALSE
## 144       West Bank and Gaza     1 -1.58746409  6.22408742 0.5641896    FALSE
## 145              Yemen, Rep.     1 -1.50029533  5.09908030 0.5641896    FALSE
## 146                   Zambia     1  5.27611349  6.19001634 0.5641896    FALSE
## 147                 Zimbabwe     1  3.06603778  9.41405698 0.5641896    FALSE
##      leaf depth .ggraph.orig_index .ggraph.index                     name
## 1   FALSE     0                  2             1                     Asia
## 2    TRUE     1                  7             2                   Europe
## 3    TRUE     1                 12             3                   Africa
## 4    TRUE     1                 15             4                 Americas
## 5    TRUE     1                 18             5                  Oceania
## 6    TRUE     1                 21             6              Afghanistan
## 7    TRUE     1                 37             7                  Albania
## 8    TRUE     1                 39             8                  Algeria
## 9    TRUE     1                 40             9                   Angola
## 10   TRUE     1                 49            10                Argentina
## 11   TRUE     1                 50            11                Australia
## 12   TRUE     1                 53            12                  Austria
## 13   TRUE     1                 55            13                  Bahrain
## 14   TRUE     1                 62            14               Bangladesh
## 15   TRUE     1                 63            15                  Belgium
## 16   TRUE     1                 68            16                    Benin
## 17   TRUE     1                 70            17                  Bolivia
## 18   TRUE     1                 90            18   Bosnia and Herzegovina
## 19   TRUE     1                 96            19                 Botswana
## 20   TRUE     1                101            20                   Brazil
## 21   TRUE     1                108            21                 Bulgaria
## 22   TRUE     1                109            22             Burkina Faso
## 23   TRUE     1                112            23                  Burundi
## 24   TRUE     1                117            24                 Cambodia
## 25   TRUE     1                120            25                 Cameroon
## 26   TRUE     1                121            26                   Canada
## 27   TRUE     1                124            27 Central African Republic
## 28   TRUE     1                128            28                     Chad
## 29   TRUE     1                129            29                    Chile
## 30   TRUE     1                137            30                    China
## 31   TRUE     1                139            31                 Colombia
## 32  FALSE    -1                  3            32                  Comoros
## 33   TRUE    -1                  8            33         Congo, Dem. Rep.
## 34   TRUE    -1                  9            34              Congo, Rep.
## 35   TRUE    -1                 16            35               Costa Rica
## 36   TRUE    -1                 19            36            Cote d'Ivoire
## 37   TRUE    -1                 22            37                  Croatia
## 38   TRUE    -1                 23            38                     Cuba
## 39   TRUE    -1                 25            39           Czech Republic
## 40   TRUE    -1                 27            40                  Denmark
## 41   TRUE    -1                 28            41                 Djibouti
## 42   TRUE    -1                 32            42       Dominican Republic
## 43   TRUE    -1                 33            43                  Ecuador
## 44   TRUE    -1                 34            44                    Egypt
## 45   TRUE    -1                 36            45              El Salvador
## 46   TRUE    -1                 41            46        Equatorial Guinea
## 47   TRUE    -1                 44            47                  Eritrea
## 48   TRUE    -1                 46            48                 Ethiopia
## 49   TRUE    -1                 47            49                  Finland
## 50   TRUE    -1                 48            50                   France
## 51   TRUE    -1                 51            51                    Gabon
## 52   TRUE    -1                 52            52                   Gambia
## 53   TRUE    -1                 54            53                  Germany
## 54   TRUE    -1                 57            54                    Ghana
## 55   TRUE    -1                 58            55                   Greece
## 56   TRUE    -1                 74            56                Guatemala
## 57   TRUE    -1                 79            57                   Guinea
## 58   TRUE    -1                 80            58            Guinea-Bissau
## 59   TRUE    -1                 81            59                    Haiti
## 60   TRUE    -1                 82            60                 Honduras
## 61   TRUE    -1                 83            61         Hong Kong, China
## 62   TRUE    -1                 85            62                  Hungary
## 63   TRUE    -1                 86            63                  Iceland
## 64   TRUE    -1                 87            64                    India
## 65   TRUE    -1                 91            65                Indonesia
## 66   TRUE    -1                 92            66                     Iran
## 67   TRUE    -1                 94            67                     Iraq
## 68   TRUE    -1                 99            68                  Ireland
## 69   TRUE    -1                100            69                   Israel
## 70   TRUE    -1                111            70                    Italy
## 71   TRUE    -1                113            71                  Jamaica
## 72   TRUE    -1                114            72                    Japan
## 73   TRUE    -1                116            73                   Jordan
## 74   TRUE    -1                118            74                    Kenya
## 75   TRUE    -1                122            75         Korea, Dem. Rep.
## 76   TRUE    -1                123            76              Korea, Rep.
## 77   TRUE    -1                126            77                   Kuwait
## 78   TRUE    -1                127            78                  Lebanon
## 79   TRUE    -1                132            79                  Lesotho
## 80   TRUE    -1                134            80                  Liberia
## 81   TRUE    -1                136            81                    Libya
## 82   TRUE    -1                138            82               Madagascar
## 83   TRUE    -1                146            83                   Malawi
## 84   TRUE    -1                147            84                 Malaysia
## 85  FALSE    -1                  4            85                     Mali
## 86   TRUE    -1                 10            86               Mauritania
## 87   TRUE    -1                 17            87                Mauritius
## 88   TRUE    -1                 20            88                   Mexico
## 89   TRUE    -1                 26            89                 Mongolia
## 90   TRUE    -1                 29            90               Montenegro
## 91   TRUE    -1                 31            91                  Morocco
## 92   TRUE    -1                 35            92               Mozambique
## 93   TRUE    -1                 38            93                  Myanmar
## 94   TRUE    -1                 42            94                  Namibia
## 95   TRUE    -1                 43            95                    Nepal
## 96   TRUE    -1                 45            96              Netherlands
## 97   TRUE    -1                 56            97              New Zealand
## 98   TRUE    -1                 59            98                Nicaragua
## 99   TRUE    -1                 60            99                    Niger
## 100  TRUE    -1                 71           100                  Nigeria
## 101  TRUE    -1                 88           101                   Norway
## 102  TRUE    -1                 98           102                     Oman
## 103  TRUE    -1                104           103                 Pakistan
## 104  TRUE    -1                105           104                   Panama
## 105  TRUE    -1                106           105                 Paraguay
## 106  TRUE    -1                110           106                     Peru
## 107  TRUE    -1                135           107              Philippines
## 108  TRUE    -1                140           108                   Poland
## 109  TRUE    -1                141           109                 Portugal
## 110  TRUE    -1                142           110              Puerto Rico
## 111 FALSE    -1                  5           111                  Reunion
## 112  TRUE    -1                 11           112                  Romania
## 113  TRUE    -1                 97           113                   Rwanda
## 114 FALSE    -1                  1           114    Sao Tome and Principe
## 115  TRUE    -1                  6           115             Saudi Arabia
## 116  TRUE    -1                 13           116                  Senegal
## 117  TRUE    -1                 14           117                   Serbia
## 118  TRUE    -1                 24           118             Sierra Leone
## 119  TRUE    -1                 30           119                Singapore
## 120  TRUE    -1                 61           120          Slovak Republic
## 121  TRUE    -1                 64           121                 Slovenia
## 122  TRUE    -1                 65           122                  Somalia
## 123  TRUE    -1                 66           123             South Africa
## 124  TRUE    -1                 67           124                    Spain
## 125  TRUE    -1                 69           125                Sri Lanka
## 126  TRUE    -1                 72           126                    Sudan
## 127  TRUE    -1                 73           127                Swaziland
## 128  TRUE    -1                 75           128                   Sweden
## 129  TRUE    -1                 76           129              Switzerland
## 130  TRUE    -1                 77           130                    Syria
## 131  TRUE    -1                 78           131                   Taiwan
## 132  TRUE    -1                 84           132                 Tanzania
## 133  TRUE    -1                 89           133                 Thailand
## 134  TRUE    -1                 93           134                     Togo
## 135  TRUE    -1                 95           135      Trinidad and Tobago
## 136  TRUE    -1                102           136                  Tunisia
## 137  TRUE    -1                103           137                   Turkey
## 138  TRUE    -1                107           138                   Uganda
## 139  TRUE    -1                115           139           United Kingdom
## 140  TRUE    -1                119           140            United States
## 141  TRUE    -1                125           141                  Uruguay
## 142  TRUE    -1                130           142                Venezuela
## 143  TRUE    -1                131           143                  Vietnam
## 144  TRUE    -1                133           144       West Bank and Gaza
## 145  TRUE    -1                143           145              Yemen, Rep.
## 146  TRUE    -1                144           146                   Zambia
## 147  TRUE    -1                145           147                 Zimbabwe
##     is_from is_to is_from_and_to node_type shape colour size fill alpha stroke
## 1      TRUE FALSE          FALSE      from    19  black  1.5   NA    NA    0.5
## 2      TRUE FALSE          FALSE      from    19  black  1.5   NA    NA    0.5
## 3      TRUE FALSE          FALSE      from    19  black  1.5   NA    NA    0.5
## 4      TRUE FALSE          FALSE      from    19  black  1.5   NA    NA    0.5
## 5      TRUE FALSE          FALSE      from    19  black  1.5   NA    NA    0.5
## 6     FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 7     FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 8     FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 9     FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 10    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 11    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 12    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 13    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 14    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 15    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 16    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 17    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 18    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 19    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 20    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 21    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 22    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 23    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 24    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 25    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 26    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 27    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 28    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 29    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 30    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 31    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 32    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 33    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 34    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 35    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 36    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 37    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 38    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 39    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 40    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 41    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 42    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 43    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 44    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 45    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 46    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 47    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 48    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 49    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 50    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 51    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 52    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 53    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 54    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 55    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 56    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 57    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 58    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 59    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 60    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 61    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 62    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 63    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 64    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 65    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 66    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 67    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 68    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 69    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 70    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 71    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 72    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 73    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 74    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 75    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 76    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 77    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 78    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 79    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 80    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 81    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 82    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 83    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 84    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 85    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 86    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 87    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 88    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 89    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 90    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 91    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 92    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 93    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 94    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 95    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 96    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 97    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 98    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 99    FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 100   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 101   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 102   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 103   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 104   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 105   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 106   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 107   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 108   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 109   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 110   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 111   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 112   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 113   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 114   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 115   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 116   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 117   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 118   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 119   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 120   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 121   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 122   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 123   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 124   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 125   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 126   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 127   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 128   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 129   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 130   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 131   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 132   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 133   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 134   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 135   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 136   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 137   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 138   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 139   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 140   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 141   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 142   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 143   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 144   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 145   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 146   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
## 147   FALSE  TRUE          FALSE        to    19  black  1.5   NA    NA    0.5
graph <- tbl_graph(flare$vertices, flare$edges)
set.seed(1)
ggraph(graph, 'circlepack', weight = size) + 
  geom_node_circle(aes(fill = depth), size = 0.25, n = 50) + 
  coord_fixed()

gapminder::gapminder %>% 
  select(continent, country) %>% 
  tidygraph::as_tbl_graph() %>% 
  ggraph(layout = "circlepack") + 
  geom_node_circle()

library(tidyverse)
pkgs <- as_tibble(tools::CRAN_package_db())
gg_pkgs <- pkgs %>% 
  select(Package, Depends, Imports, Suggests) %>% 
  filter(
    str_detect(Package, "^gg"),
    if_any(-Package, ~ str_detect(.x, "ggplot2"))
  ) %>% 
  mutate(
    dep_grid = str_detect(Depends, "\\bgrid\\b") | str_detect(Imports, "\\bgrid\\b"),
    dep_dplyr = str_detect(Depends, "\\bdplyr\\b") | str_detect(Imports, "\\bdplyr\\b")
  ) %>% 
  drop_na()

gg_pkgs %>%
pivot_longer(cols = dep_grid:dep_dplyr) %>%
filter(value == T) %>%
  ggplot() + 
  aes(from = Package, to = name) + 
  geom_point(stat = StatEdgelistNodes) + 
  geom_segment(stat = StatEdgelistEdges)
## Joining with `by = join_by(from)`
## Joining with `by = join_by(to)`

Experiment

Closing remarks, Other Relevant Work, Caveats