Skip to contents

Retrieve supply and use parts for each commodity balance sheet (CBS) item. Stock variations are split into two non-negative columns following the FABIO methodology.

Usage

get_wide_cbs(
  years = NULL,
  trade_recovery = .cbs_trade_recovery_choices(),
  example = FALSE
)

Arguments

years

Optional integer vector of years to return. When NULL (default) the whole series is returned. A window returns exactly those years of the full-range result. The balances themselves are always built over the whole series, once per session and then cached, because several of their gap fills carry an observation across the whole year axis: a balance built over the window alone would differ from the same years of the full build (whep#833). A window therefore costs as much as the full series the first time, and nothing after that.

trade_recovery

One of "byproduct_residual" (default), "pass_through", "net_import" or "none", passed to build_commodity_balances(), which documents what each does and what the default moves. Each method is built and cached under its own slot, so asking for one never serves the other's result.

example

If TRUE, return a small example output without downloading remote data. Default is FALSE. The example is the same fixture under either trade_recovery.

Value

A tibble with the commodity balance sheet data in wide format. It contains the following columns:

  • year: The year in which the recorded event occurred.

  • area_code: The code of the country where the data is from. For code details see e.g. add_area_name().

  • item_cbs_code: FAOSTAT internal code for each item. For code details see e.g. add_item_cbs_name().

  • unit: The denomination of every quantity in the row. "tonnes" for the rows of the FAO-style balance sheet and "heads" (number of animals) for the live-animal rows added by the livestock balance. Set by the builder that produced the row, so a derived row carries the same unit as a reported one. Never sum quantities across rows of different units.

The other columns are quantities where total supply and total use should be balanced, in the row's unit.

For supply:

  • production: Produced locally.

  • import: Obtained from importing from other countries.

  • stock_withdrawal: Biomass taken out of storage (non-negative). Positive when stocks decrease.

For use:

  • food: Food for humans.

  • feed: Food for animals.

  • export: Released as export for other countries.

  • seed: Intended for new production.

  • processing: Used to obtain other subproducts.

  • processing_primary: Used to obtain other subproducts, for the handful of primary items (palm fruit, hops, seed cotton, coconuts, hemp, kapok fruit, linum) whose entire domestic supply is destined for processing. Zero for every other item.

  • other_uses: Any other use not included above.

  • stock_addition: Biomass placed into storage (non-negative). Positive when stocks increase.

There is an additional column domestic_supply which is computed as total use excluding export.

The live-animal rows also carry method_cull, saying where the slaughter of culled dairy cattle and laying hens was booked (see the argument of that name in get_livestock_cbs()); it is NA on the tonnes rows.

Examples

get_wide_cbs(example = TRUE)
#> # A tibble: 10 × 19
#>     year area_code polity_area_code reporting_polity_code reporting_polity_name 
#>    <int>     <int>            <int> <chr>                 <chr>                 
#>  1  1987       250              250 COD-1960-2025         Democratic Republic o…
#>  2  2012        41               41 CHN-1950-2025         China (PRC)           
#>  3  1984       123              123 LBR-1847-2025         Liberia               
#>  4  1982       165              165 PAK-1971-2025         Pakistan              
#>  5  1977       159              159 NGA-1961-2025         Nigeria               
#>  6  1995       234              234 URY-1828-2025         Uruguay               
#>  7  1975        10               10 AUS-1901-2025         Australia             
#>  8  1961       156              156 NZL-1840-2025         New Zealand           
#>  9  1961       236              236 VEN-1830-2025         Venezuela             
#> 10  1995        49               49 CUB-1800-2025         Cuba                  
#> # ℹ 14 more variables: reporting_polity_has_geometry <lgl>,
#> #   item_cbs_code <dbl>, unit <chr>, domestic_supply <dbl>, food <dbl>,
#> #   production <dbl>, feed <dbl>, seed <dbl>, import <dbl>, export <dbl>,
#> #   other_uses <dbl>, processing <dbl>, stock_withdrawal <dbl>,
#> #   stock_addition <dbl>