find_p_industry_names | R Documentation |
Primary industry names are needed for aggregation.
This function interrogates the row names of R and V and the column names Y matrices
for names that start with p_industries
.
The assumption is that many of these row and column names may have
compound names of the form "Resources [of Oil and gas extraction]".
So this function looks for leading strings.
If "Resources" is in p_industries
,
"Resources [of Oil and gas extraction]" will be among the returned strings.
find_p_industry_names(
.sutdata = NULL,
p_industry_prefixes = Recca::industry_cols$p_industry_prefixes,
R = Recca::psut_cols$R,
V = Recca::psut_cols$V,
Y = Recca::psut_cols$Y,
p_industries_complete = Recca::industry_cols$p_industries_complete
)
.sutdata |
An optional data frame containing columns of PSUT matrices |
p_industry_prefixes |
The name of a column in |
R |
The name of the |
V |
The name of the |
Y |
The name of the |
p_industries_complete |
The name of the output column containing complete names of primary industries.
Default is |
Note all of R
, V
, and Y
need to be specified.
If .sutdata
is a data frame, a data frame with additional column p_industries_complete
.
If .sutdata
is a list of named matrices (R
, V
, and Y
),
A vector or vectors of full names of primary industries in the R
, V
, and Y
matrices,
a list of primary industries.
Rrows <- c("Resources [of Oil and gas extraction]", "Resources [of Coal mines]")
R <- matrix(c(1, 0,
0, 2), nrow = 2, byrow = TRUE,
dimnames = list(Rrows, c("Crude oil", "Brown coal")))
Vrows <- c("Imports [of Crude oil]", "Stock changes [of Bituminous coal]")
V <- matrix(c(3, 0,
0, 4), nrow = 2, byrow = TRUE,
dimnames = list(Vrows, c("Crude oil", "Bituminous coal")))
Ycols <- c("Exports [of Electricity]", "International marine bunkers [of Gas/diesel oil]")
Y <- matrix(c(5, 0,
0, 6), nrow = 2, byrow = TRUE,
dimnames = list(c("Electricity", "Gas/diesel oil"), Ycols))
p_industry_prefixes <- c("Resources", "Imports", "Exports",
"Stock changes", "International marine bunkers")
# This function works with individual matrices, so long as they are
# first wrapped in `list()`.
find_p_industry_names(p_industry_prefixes = list(p_industry_prefixes),
R = list(R), V = list(V), Y = list(Y))
# Also works in the context of a data frame.
# Use a `tibble`, because it handles matrices better
res <- tibble::tibble(R = list(R,R), V = list(V,V), Y = list(Y,Y),
p_industries = list(p_industry_prefixes, "Resources")) %>%
find_p_industry_names(p_industry_prefixes = "p_industries")
res$p_industries_complete[[1]]
res$p_industries_complete[[2]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.