Node- and edge-level summaries of a bilateral flow table: who sends, who
receives, who is central. No igraph required – at country scale the dense
arithmetic is trivial.
Value
A list of two tibbles:
nodes–iso3c,country,out_flow,in_flow,net_flow,out_degree,in_degreeandstrength_share(the country's share of all flow, in or out).edges–from,to,weight,shareandreciprocity(the opposite flow as a proportion of this one;NAwhere there is none).
Examples
od <- data.frame(
from = c("China", "China", "Germany", "USA", "Mexico"),
to = c("USA", "Germany", "France", "Mexico", "USA"),
value = c(500, 100, 80, 300, 320)
)
country_network(od, from, to, value)
#> $nodes
#> # A tibble: 5 × 8
#> iso3c country out_flow in_flow net_flow out_degree in_degree strength_share
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 USA United St… 300 820 -520 1 2 0.431
#> 2 MEX Mexico 320 300 20 1 1 0.238
#> 3 CHN China 600 0 600 2 0 0.231
#> 4 DEU Germany 80 100 -20 1 1 0.0692
#> 5 FRA France 0 80 -80 0 1 0.0308
#>
#> $edges
#> # A tibble: 5 × 5
#> from to weight share reciprocity
#> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 CHN USA 500 0.385 NA
#> 2 MEX USA 320 0.246 0.938
#> 3 USA MEX 300 0.231 1.07
#> 4 CHN DEU 100 0.0769 NA
#> 5 DEU FRA 80 0.0615 NA
#>
