From 6ba9f0168fcbe745c754f53c4456b3130a606747 Mon Sep 17 00:00:00 2001 From: Falk Benke Date: Mon, 9 Sep 2024 15:16:19 +0200 Subject: [PATCH] fix bug in convertGEA2012 --- R/convertGEA2012.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/convertGEA2012.R b/R/convertGEA2012.R index d6f1d32c..faf8d640 100644 --- a/R/convertGEA2012.R +++ b/R/convertGEA2012.R @@ -58,6 +58,12 @@ convertGEA2012 <- function(x, subtype) { if (subtype %in% c("oil", "coal", "gas")) { + # a hack: we must reformat the subdimension 'grade' so that its values are not + # integers, which causes the internal conversion back to maglass to wrongly guess + # the year dimension + + getNames(out, dim = 4) <- paste0(getNames(out, dim = 4), "-grade") + # convert T US$2005/TWa -> T US$2017/TWa for cost factors xi1 and xi2 tmp <- GDPuc::convertGDP( gdp = out[, , c("xi1", "xi2")], @@ -68,6 +74,9 @@ convertGEA2012 <- function(x, subtype) { out <- mbind(tmp, out[, , c("xi1", "xi2"), invert = TRUE]) + # undo the hack after conversion + getNames(out, dim = 4) <- gsub("-grade", "", getNames(x, dim = 4)) + } else { out <- x }