Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read in energy prices and taxes #628

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions R/convertIEA_EnergyPrices.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' Convert IEA Energy Prices
#'
#' @author Falk Benke
#' @importFrom madrat toolCountry2isocode
convertIEA_EnergyPrices <- function(x) {
# remove regions
x <- x[c("OECDEUR", "OECDTOT"), , invert = TRUE]
getItems(x, dim = 1) <- toolCountry2isocode(getItems(x, dim = 1))

# remove quarterly data
x <- x[, !grepl("^[1-4]Q", getYears(x)), invert = TRUE]

x <- toolCountryFill(x, NA, verbosity = 2)
return(x)
}
17 changes: 17 additions & 0 deletions R/readIEA_EnergyPrices.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' Read IEA Energy Prices
#'
#' Read-in an IEA Energy Prices file as magpie object
#'
#' @author Falk Benke
#' @importFrom data.table
#' @importFrom madrat as.magpie
readIEA_EnergyPrices <- function() {
data <- data.table::fread(
file = file.path("2022", "EPT_prices_USD.TXT"),
col.names = c("SECTOR", "COUNTRY", "PRODUCT", "UNIT", "TIME", "value"),
colClasses = c("character", "character", "character", "character", "character", "numeric"),
sep = " ", stringsAsFactors = FALSE, na.strings = c("x", "..", "c"), skip = 0, showProgress = FALSE
)

return(as.magpie(data, spatial = 2, temporal = 5))
}
Loading