Skip to contents

Remove columns and their corresponding rows if they contain only zeros or missing values. This ensures that the resulting table remains symmetric (same dimensions in rows and columns).

Usage

empty_remove(data_table)

Arguments

data_table

A symmetric input–output table, or the symmetric quadrant of a use or supply table.

Value

A data.frame (or tibble) with a key column and symmetric matrix, after removing all-zero (or all-missing) columns and their corresponding rows.

Details

The function first identifies columns that contain only zeros or missing values, then removes both those columns and the rows with matching labels in the first (key) column. A message is printed listing the removed columns.

Examples

# Example using the built-in demo table
test_table <- input_coefficient_matrix_create(
  iotable_get(source = "germany_1995")
)

# Set one column to zero, then remove it
test_table[, 2] <- 0
empty_remove(test_table)
#> Columns and rows of agriculture_group are all zeros and will be removed.
#>              iotables_row industry_group construction trade_group
#> 2          industry_group    0.282166963  0.261259904 0.076068903
#> 3            construction    0.006794226  0.015777302 0.009806263
#> 4             trade_group    0.067365111  0.057775462 0.137759854
#> 5 business_services_group    0.089041045  0.126328347 0.121754314
#> 6    other_services_group    0.013883047  0.007113018 0.020784612
#>   business_services_group other_services_group
#> 2              0.01730141           0.05965598
#> 3              0.03387356           0.01798915
#> 4              0.01564650           0.04127973
#> 5              0.27895975           0.06724659
#> 6              0.02174481           0.04336651