#' Read in the components of an IO table for analysis.
#'
#' Reads in an IO table not included in the package data to enable analysis using other tables. External IO tables must be
#' in Microsoft Excel .xlsx format.
#'
#' @param filepath path to the folder containing the IO table.
#' @param table name of the xlsx file containing the IO table.
#' @param sheet name of the worksheet in the excel file which contains the flow table.
#' @param f_range cell range in the excel sheet which contains the flow table, including column labels.
#' @param hhold_demand_range cell range in the excel sheet which contains the vector of household demands.
#' @param hhold_output_range cell range in the excel sheet which contains the vector of household output (total employee compensation).
#' @param final_demand_range cell range in the excel sheet which contains the vector of final demands (total demand/output minus the inter-industry demands).
#' @param total_output_range cell range in the excel sheet which contains the vector of total output.
#'
#' @return `flowtable`
#' @return `hhold.output`
#' @return `hhold.demand`
#' @return `total.output`
#' @return `final.demand`
#'
#' @export
read_iotable <- function(filepath = NULL,
table = NULL,
sheet = NULL,
f_range = NULL,
hhold_output_range = NULL,
hhold_demand_range = NULL,
total_output_range = NULL,
final_demand_range = NULL
) {
### Read in the flowtable
flowtable <- read_excel(path = paste0(filepath,table,".xlsx"),
sheet = sheet,
range = f_range,
col_names = TRUE)
### Read in the household consumption/demand and output rows
hhold.output <- read_excel(path = paste0(filepath,table,".xlsx"),
sheet = sheet,
range = hhold_output_range,
col_names = FALSE)
hhold.demand <- read_excel(path = paste0(filepath,table,".xlsx"),
sheet = sheet,
range = hhold_demand_range,
col_names = FALSE)
### Read in the final demand and total output
total.output <- read_excel(path = paste0(filepath,table,".xlsx"),
sheet = sheet,
range = total_output_range,
col_names = FALSE)
final.demand <- read_excel(path = paste0(filepath,table,".xlsx"),
sheet = sheet,
range = final_demand_range,
col_names = FALSE)
### return as matrices/vectors and put into a list
list = list(flowtable = as.matrix(flowtable),
hhold.output = as.vector(as.matrix(hhold.output)),
hhold.demand = as.vector(as.matrix(hhold.demand)),
total.output = as.vector(as.matrix(total.output)),
final.demand = as.vector(as.matrix(final.demand)) )
return(list)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.