Add a conforming row, or elements of a conforming row, to a named input–output style data frame.
Arguments
- data_table
A symmetric input–output table, a use table, a margins table, or a tax table retrieved by
iotable_get().- rows_to_add
A data frame or a named numeric vector containing the new row(s).
- row_names
Optional character vector giving names for the new key column. If
NULL, names are inferred (see Details).- empty_fill
Value used to fill missing columns. Defaults to
0.
Details
You can add rows in several ways:
A data frame with one or more rows, where the first column contains row identifiers.
A named numeric vector, which will be turned into a single-row data frame.
If no row_names are supplied and the first column of rows_to_add is
numeric, new rows will be automatically labelled as "new_row_1",
"new_row_2", etc.
Missing column values are filled with empty_fill, which defaults to 0.
If you want to avoid division by zero in later computations, you can set
this to a very small value (e.g. 1e-6).
See also
Other iotables processing functions:
conforming_vector_create(),
empty_remove(),
household_column_find(),
household_column_get(),
iotable_year_get(),
key_column_create(),
matrix_round(),
output_get(),
primary_input_get(),
supplementary_add(),
total_tax_add(),
vector_transpose_longer(),
vector_transpose_wider()
Examples
rows_to_add <- data.frame(
iotables_row = "CO2_emission",
agriculture_group = 10448,
industry_group = 558327, # construction is omitted
trade_group = 11194
)
rows_add(iotable_get(), rows_to_add = rows_to_add)
#> iotables_row agriculture_group industry_group construction
#> 1 agriculture_group 1131 25480 1
#> 2 industry_group 7930 304584 64167
#> 3 construction 426 7334 3875
#> 4 trade_group 3559 72717 14190
#> 5 business_services_group 3637 96115 31027
#> 6 other_services_group 1552 14986 1747
#> 7 total 18235 521216 115007
#> 8 imports 2927 156703 13427
#> 9 intermediate_consumption 22246 684424 129982
#> 10 compensation_employees 9382 296464 78819
#> 11 net_tax_production -2012 1457 963
#> 12 consumption_fixed_capital 7871 63769 5860
#> 13 os_mixed_income_net 6423 33332 29982
#> 14 gva 21664 395022 115624
#> 15 output 43910 1079446 245606
#> 16 net_tax_products 1084 6505 1548
#> 17 employment_wage_salary 483 8032 2896
#> 18 employment_self_employed 613 349 340
#> 19 employment_domestic_total 1096 8381 3236
#> 20 CO2_emission 10448 558327 0
#> trade_group business_services_group other_services_group total
#> 1 607 710 762 28691
#> 2 41082 11981 30360 460104
#> 3 5296 23457 9155 49543
#> 4 74399 10835 21008 196708
#> 5 65755 193176 34223 423933
#> 6 11225 15058 22070 66638
#> 7 198364 255217 117578 1225617
#> 8 21943 13371 13772 222143
#> 9 228656 277061 143901 1486270
#> 10 214450 124810 272975 996900
#> 11 2748 5946 -8602 500
#> 12 41100 98610 49260 266470
#> 13 53109 186060 51384 360290
#> 14 311407 415426 365017 1624160
#> 15 540063 692487 508918 3110430
#> 16 8349 8473 12551 38510
#> 17 7977 3653 9555 32596
#> 18 1274 605 651 3832
#> 19 9251 4258 10206 36428
#> 20 11194 0 0 0
#> final_consumption_households final_consumption_government inventory_change
#> 1 8500 16 -6
#> 2 197792 8588 7559
#> 3 3457 742 0
#> 4 269663 13492 0
#> 5 214757 10061 0
#> 6 119504 317251 0
#> 7 813673 350150 7553
#> 8 80187 2970 -4233
#> 9 1001060 356790 3580
#> 10 NA NA NA
#> 11 NA NA NA
#> 12 NA NA NA
#> 13 NA NA NA
#> 14 NA NA NA
#> 15 1001060 356790 3580
#> 16 107200 3670 260
#> 17 NA NA NA
#> 18 NA NA NA
#> 19 NA NA NA
#> 20 0 0 0
#> gross_capital_formation exports total_final_use
#> 1 2975 3734 43910
#> 2 91692 313711 1079400
#> 3 191715 149 245606
#> 4 14155 46045 540063
#> 5 30124 13612 692487
#> 6 3483 2042 508918
#> 7 334144 379293 3110384
#> 8 41436 42597 385100
#> 9 404240 420730 3672624
#> 10 NA NA 996900
#> 11 NA NA 500
#> 12 NA NA 266470
#> 13 NA NA 360290
#> 14 NA NA 1624160
#> 15 404240 420730 NA
#> 16 28660 -1160 177140
#> 17 NA NA 32596
#> 18 NA NA 3832
#> 19 NA NA 36428
#> 20 0 0 0
rows_add(iotable_get(),
rows_to_add = c(
industry_group = 1534,
trade_group = 4
),
row_names = "CH4_emission"
)
#> iotables_row agriculture_group industry_group construction
#> 1 agriculture_group 1131 25480 1
#> 2 industry_group 7930 304584 64167
#> 3 construction 426 7334 3875
#> 4 trade_group 3559 72717 14190
#> 5 business_services_group 3637 96115 31027
#> 6 other_services_group 1552 14986 1747
#> 7 total 18235 521216 115007
#> 8 imports 2927 156703 13427
#> 9 intermediate_consumption 22246 684424 129982
#> 10 compensation_employees 9382 296464 78819
#> 11 net_tax_production -2012 1457 963
#> 12 consumption_fixed_capital 7871 63769 5860
#> 13 os_mixed_income_net 6423 33332 29982
#> 14 gva 21664 395022 115624
#> 15 output 43910 1079446 245606
#> 16 net_tax_products 1084 6505 1548
#> 17 employment_wage_salary 483 8032 2896
#> 18 employment_self_employed 613 349 340
#> 19 employment_domestic_total 1096 8381 3236
#> 20 CH4_emission 0 1534 0
#> trade_group business_services_group other_services_group total
#> 1 607 710 762 28691
#> 2 41082 11981 30360 460104
#> 3 5296 23457 9155 49543
#> 4 74399 10835 21008 196708
#> 5 65755 193176 34223 423933
#> 6 11225 15058 22070 66638
#> 7 198364 255217 117578 1225617
#> 8 21943 13371 13772 222143
#> 9 228656 277061 143901 1486270
#> 10 214450 124810 272975 996900
#> 11 2748 5946 -8602 500
#> 12 41100 98610 49260 266470
#> 13 53109 186060 51384 360290
#> 14 311407 415426 365017 1624160
#> 15 540063 692487 508918 3110430
#> 16 8349 8473 12551 38510
#> 17 7977 3653 9555 32596
#> 18 1274 605 651 3832
#> 19 9251 4258 10206 36428
#> 20 4 0 0 0
#> final_consumption_households final_consumption_government inventory_change
#> 1 8500 16 -6
#> 2 197792 8588 7559
#> 3 3457 742 0
#> 4 269663 13492 0
#> 5 214757 10061 0
#> 6 119504 317251 0
#> 7 813673 350150 7553
#> 8 80187 2970 -4233
#> 9 1001060 356790 3580
#> 10 NA NA NA
#> 11 NA NA NA
#> 12 NA NA NA
#> 13 NA NA NA
#> 14 NA NA NA
#> 15 1001060 356790 3580
#> 16 107200 3670 260
#> 17 NA NA NA
#> 18 NA NA NA
#> 19 NA NA NA
#> 20 0 0 0
#> gross_capital_formation exports total_final_use
#> 1 2975 3734 43910
#> 2 91692 313711 1079400
#> 3 191715 149 245606
#> 4 14155 46045 540063
#> 5 30124 13612 692487
#> 6 3483 2042 508918
#> 7 334144 379293 3110384
#> 8 41436 42597 385100
#> 9 404240 420730 3672624
#> 10 NA NA 996900
#> 11 NA NA 500
#> 12 NA NA 266470
#> 13 NA NA 360290
#> 14 NA NA 1624160
#> 15 404240 420730 NA
#> 16 28660 -1160 177140
#> 17 NA NA 32596
#> 18 NA NA 3832
#> 19 NA NA 36428
#> 20 0 0 0
