rows_add: Add conforming row(s)

View source: R/rows_add.R

rows_addR Documentation

Add conforming row(s)

Description

Add a conforming row, or elements of a conforming row to a names matrix.

Usage

rows_add(data_table, rows_to_add, row_names = NULL, empty_fill = 0)

Arguments

data_table

A symmetric input-output table, a use table, a margins or tax table retrieved by the iotable_get function.

rows_to_add

A data frame or a named numeric vector.

row_names

An optional name or vector of names for the key column. Defaults to NULL.

empty_fill

What should happen with missing column values? Defaults to 0. If you want to avoid division by zero, you may consider a very small value such as 0.000001.

Details

If you want to add a single row manually, you can input a named numeric vector or a data frame with a single row. For multiple rows, input them as wide form data frame (see examples.)

Value

An extended data_table with the new row(s) binded.

See Also

Other iotables processing functions: conforming_vector_create(), 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)

rows_add (iotable_get(), 
          rows_to_add = c(industry_group    =  1534, 
                          trade_group       =  4),
          row_names    = "CH4_emission" )

rOpenGov/iotables documentation built on Jan. 26, 2024, 3:06 a.m.