Skip to contents

read_figaro() reads a pair of Eurostat FIGARO industry-by-industry flat-format CSV files (one supply, one use) from a single directory and returns the canonical sube_suts long table with columns REP, PAR, CPA, VAR, VALUE, YEAR, and TYPE. The output feeds directly into extract_domestic_block(), build_matrices(), and compute_sube() without modification.

Usage

read_figaro(
  path,
  year,
  final_demand_vars = c("P3_S13", "P3_S14", "P3_S15", "P51G", "P5M")
)

Arguments

path

Directory containing one FIGARO supply file and one FIGARO use file. Neither a single-file path nor recursive directory scanning is supported.

year

Four-digit integer reference year for the data (the year encoded in the FIGARO filename, e.g. 2023 in flatfile_eu-ic-supply_25ed_2023.csv). Required; there is no auto-inference from the filename.

final_demand_vars

Character vector of FIGARO colPi codes to sum into the synthetic VAR = "FU_bas" row on the use file. Defaults to the full FIGARO final-demand set. Every supplied code must exist in the use file's colPi column; unknown codes are a hard error.

Value

An object of class c("sube_suts", "data.table", "data.frame") with columns REP, PAR, CPA, VAR, VALUE, YEAR, TYPE.

Details

The function expects a directory containing exactly one supply file and exactly one use file. Files are identified by filename: supply files match -supply- or _supply_ (case-insensitive), use files match -use- or _use_. Zero or multiple matches on either side is a hard error. Single-file input is not supported in this release.

Primary-input rows (rowPi values not starting with CPA_, e.g. B2A3G, D1, D21X31, D29X39, OP_RES, OP_NRES) are dropped during import because they are SNA/ESA value-added blocks, not products. The CPA_ prefix on the remaining rowPi values is stripped so product codes match NACE-style industry codes lexically.

FIGARO publishes five final-demand codes (P3_S13, P3_S14, P3_S15, P51G, P5M). On the use file these are summed per (REP, PAR, CPA) into a single synthetic row with VAR = "FU_bas" so the result consumes cleanly with build_matrices() final_demand_var = "FU_bas". Pass a custom character vector to final_demand_vars to override the aggregation set (e.g. only household consumption).

FIGW1 (FIGARO rest-of-world 1) is a real country code in FIGARO releases and is preserved in the output alongside real country codes.

Full FIGARO flat files (e.g. the 25th-edition 2023 release) are approximately 400–500 MB each and expand to roughly 3–5 GB of peak resident memory during data.table::fread(). Ensure sufficient RAM before calling read_figaro() on a production release. The synthetic fixture under inst/extdata/figaro-sample/ is a few kilobytes and is intended for tests and examples only.

The year argument should match the reference / data year encoded in the FIGARO filename (e.g. 2023 in flatfile_eu-ic-supply_25ed_2023.csv), not the edition or release year.