From cdc034f966847712f8c02fc8166a8e973879f780 Mon Sep 17 00:00:00 2001 From: Fsioutas Date: Fri, 9 Feb 2024 15:33:35 +0200 Subject: [PATCH 1/3] add function readPRIMESPROCTECH --- R/readPRIMESPROCTECH.R | 41 +++++++++++++++++++++++++++++++++++++++ man/readPRIMESPROCTECH.Rd | 23 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 R/readPRIMESPROCTECH.R create mode 100644 man/readPRIMESPROCTECH.Rd diff --git a/R/readPRIMESPROCTECH.R b/R/readPRIMESPROCTECH.R new file mode 100644 index 00000000..7c0c2fa0 --- /dev/null +++ b/R/readPRIMESPROCTECH.R @@ -0,0 +1,41 @@ +#' readPRIMESPROCTECH +#' +#' Read PRIMES tech data and convert it to a magpie object +#' +#' @return The read-in data into magpie object. +#' +#' @author Anastasis Giannousakis, Fotis Sioutas, Giannis Tolios +#' +#' @examples +#' \dontrun{ +#' a <- readSource("PRIMESPROCTECH") +#' } +#' +#' @importFrom dplyr select +#' @importFrom tidyr unite +#' @importFrom quitte as.quitte +#' @importFrom readxl read_excel + +readPRIMESPROCTECH <- function() { + + x <- read_excel("PrindV6_process_techdata.xlsx", + sheet = "ProcessTech", range = "A2:AS291") + + df <- x[1 : 235, c(1, 2, 3, 4, 5, 36, 37, 38, 39, 6, 7, 10, 15)] + + names(df) <- sub("...1", "process", names(df)) + names(df) <- sub("...2", "tech", names(df)) + names(df) <- sub("...39", "EUR/t", names(df)) + names(df) <- sub("...36", "tech_sum", names(df)) + names(df) <- sub("Inv_costprocess5", "Inv_cost_ORD", names(df)) + names(df) <- sub("Lifettech020", "Lifetime2020", names(df)) + + x[, 3] <- as.numeric(unlist(x[, 3])) + x[, 4] <- as.numeric(unlist(x[, 4])) + x[, 5] <- as.numeric(unlist(x[, 5])) + x[, 6] <- as.numeric(unlist(x[, 6])) + + x <- as.magpie(x) + + return(x) +} \ No newline at end of file diff --git a/man/readPRIMESPROCTECH.Rd b/man/readPRIMESPROCTECH.Rd new file mode 100644 index 00000000..4049ef9a --- /dev/null +++ b/man/readPRIMESPROCTECH.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/readPRIMESPROCTECH.R +\name{readPRIMESPROCTECH} +\alias{readPRIMESPROCTECH} +\title{readPRIMESPROCTECH} +\usage{ +readPRIMESPROCTECH() +} +\value{ +The read-in data into magpie object. +} +\description{ +Read PRIMES tech data and convert it to a magpie object +} +\examples{ +\dontrun{ +a <- readSource("PRIMESPROCTECH") +} + +} +\author{ +Anastasis Giannousakis, Fotis Sioutas, Giannis Tolios +} From 93553bb0a015755f840f0927214a305a3a28a9a6 Mon Sep 17 00:00:00 2001 From: Fsioutas Date: Fri, 9 Feb 2024 16:14:17 +0200 Subject: [PATCH 2/3] changes to readPRIMESPROCTECH --- R/readPRIMESPROCTECH.R | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/R/readPRIMESPROCTECH.R b/R/readPRIMESPROCTECH.R index 7c0c2fa0..5a844643 100644 --- a/R/readPRIMESPROCTECH.R +++ b/R/readPRIMESPROCTECH.R @@ -23,19 +23,12 @@ readPRIMESPROCTECH <- function() { df <- x[1 : 235, c(1, 2, 3, 4, 5, 36, 37, 38, 39, 6, 7, 10, 15)] - names(df) <- sub("...1", "process", names(df)) - names(df) <- sub("...2", "tech", names(df)) + names(df) <- sub("...1", "tech", names(df)) + names(df) <- sub("...2", "process", names(df)) names(df) <- sub("...39", "EUR/t", names(df)) names(df) <- sub("...36", "tech_sum", names(df)) - names(df) <- sub("Inv_costprocess5", "Inv_cost_ORD", names(df)) - names(df) <- sub("Lifettech020", "Lifetime2020", names(df)) - - x[, 3] <- as.numeric(unlist(x[, 3])) - x[, 4] <- as.numeric(unlist(x[, 4])) - x[, 5] <- as.numeric(unlist(x[, 5])) - x[, 6] <- as.numeric(unlist(x[, 6])) - x <- as.magpie(x) + df <- as.magpie(df) - return(x) + return(df) } \ No newline at end of file From 60fbd4e3263eea9095362a92375ebc5c0fe48f88 Mon Sep 17 00:00:00 2001 From: Fsioutas Date: Mon, 12 Feb 2024 12:33:57 +0200 Subject: [PATCH 3/3] changes to function readPRIMESPROCTECH --- DESCRIPTION | 2 +- R/readPRIMESPROCTECH.R | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 74270ae8..8569c779 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mrprom Type: Package Title: Functions for generating input data for OPEN-PROM -Version: 0.30.3 +Version: 1.1.0 Author: Anastasis Giannousakis, Fotis Sioutas, Giannis Tolios Maintainer: Fotis Sioutas Description: mrprom can be run standalone or (preferably) in diff --git a/R/readPRIMESPROCTECH.R b/R/readPRIMESPROCTECH.R index 5a844643..bd0ee070 100644 --- a/R/readPRIMESPROCTECH.R +++ b/R/readPRIMESPROCTECH.R @@ -11,8 +11,6 @@ #' a <- readSource("PRIMESPROCTECH") #' } #' -#' @importFrom dplyr select -#' @importFrom tidyr unite #' @importFrom quitte as.quitte #' @importFrom readxl read_excel @@ -23,10 +21,12 @@ readPRIMESPROCTECH <- function() { df <- x[1 : 235, c(1, 2, 3, 4, 5, 36, 37, 38, 39, 6, 7, 10, 15)] - names(df) <- sub("...1", "tech", names(df)) + names(df) <- sub("...1", "variable", names(df)) names(df) <- sub("...2", "process", names(df)) names(df) <- sub("...39", "EUR/t", names(df)) - names(df) <- sub("...36", "tech_sum", names(df)) + names(df) <- sub("...36", "variable_sum", names(df)) + names(df) <- sub("Lifetprocess020", "Lifetime2020", names(df)) + names(df) <- sub("Inv_costvariable5", "Inv_cost_ORD", names(df)) df <- as.magpie(df)