#' This function produces annual well capacity for each well in each year.
#' @param tax_amount is the amount of tax on the unit of groundwater extracted. Defaults to 1.1.
#' @param well_capacity_for_econ is the file name that all the output well capacities are written into. Defaults to "C:/Users/manirad/Downloads/test/Econ_output/well_capacity.csv".
#' @param first_year_of_simulation is the first year that the hydro-economic simulation starts. Defaults to 2000.
#' @param default_well_capacity_col_name is the name of the well capacity column generated from the MODFLOW model. Defaults to 'Well_Capacity(gpm)' as this is the original column name we started with.
#' @return returns the output table.
#' @examples
#' \dontrun{
#' gen_lookup_tax(tax_amount = 2)
#' }
#' @export
gen_output_tax = function (tax_amount = 1,
well_capacity_files = "./Well Capacity",
well_capacity_for_econ = "./Econ_output/well_capacity.csv",
first_year_of_simulation = 2000,
default_well_capacity_col_name = "Well_Capacity(gpm)")
{
tax_amount = (tax_amount - 1)/10
filenames = list.files(path = well_capacity_files, pattern = "*.csv",
full.names = TRUE)
ldf <- lapply(filenames, fread, fill = T)
ldf <- mapply(cbind, ldf, file_name = filenames, SIMPLIFY = F)
ldf = rbindlist(ldf)
foo = data.table::data.table(Well_ID = 1, V1 = 1, file_name = paste0(well_capacity_files,
"/", first_year_of_simulation, "_Capacity.csv"))
setnames(foo, old = "V1", new = default_well_capacity_col_name)
ldf = rbind(ldf, foo)
ldf[, `:=`(file_name, substr(file_name, nchar(file_name) -
16, nchar(file_name) - 13))]
ldf[, `:=`(file_name, as.integer(file_name))]
ldf[, `:=`(tax, tax_amount)]
# write.table(ldf, sep = ",", file = well_capacity_for_econ,
# row.names = F, col.names = !file.exists(well_capacity_for_econ),
# append = T)
write.csv(ldf, well_capacity_for_econ, row.names = F)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.