set_zero: Set to zero specific rows and columns of a matrix

View source: R/matrix_extract.R

set_zeroR Documentation

Set to zero specific rows and columns of a matrix

Description

Sets to zero specific rows and columns of a matrix, to include and exclude specific geographical and sector effects.

Usage

set_zero(df, orig = NULL, dest = NULL, wiotype = NULL, invert = FALSE)

Arguments

df

A matrix with named rows and columns.

orig

A vector of integers with position of rows or a list of strings with codes of country and sector of origin.

dest

A vector of integers with position of columns or a list of strings with codes of country and sector of destination.

wiotype

String, type of wio. Required if origin or destination is specified with lists of codes.

invert

Boolean: FALSE (default) to set to zero the specified countries and sectors, or TRUE to set to zero the non-specified countries and sectors.

Value

The same matrix with specific rows and columns set to zero.

Examples

wio <- make_wio("wiodtest")
# Set to zero Spanish exports of intermediates of manufacturing to
# non EU27 countries (for any sector of destination) in the coefficient
# matrix A
set_zero(wio$A, list("ESP", "MANUF"), list("NONEU27", "TOTAL"), "wiodtest")
# Set to zero Spanish exports of intermediates (extraction matrix of Spain)
set_zero(wio$A, list("ESP", "TOTAL"), list("WLDxESP", "TOTAL"), "wiodtest")

exvatools documentation built on May 29, 2024, 6:46 a.m.