Convert the bilateral_trade list-column of get_bilateral_trade()
(one square origin-by-destination matrix per year and item) into
the tidy from_code/to_code long form consumed by
compute_footprint_balance(). Self-trade (diagonal) entries are
dropped.
Arguments
- bilateral_trade
Tibble from
get_bilateral_trade(), withyear,item_cbs_codeand abilateral_tradematrix list-column.
Examples
m <- matrix(
c(0, 40, 0, 0),
nrow = 2,
dimnames = list(c("1", "2"), c("1", "2"))
)
bt <- tibble::tibble(
year = 2010L, item_cbs_code = 10L, bilateral_trade = list(m)
)
melt_bilateral_trade(bt)
#> # A tibble: 1 × 5
#> year from_code to_code item_cbs_code value
#> <int> <int> <int> <int> <dbl>
#> 1 2010 2 1 10 40
