diff --git a/.buildlibrary b/.buildlibrary index 7dfc8c7..1d20f87 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '2097375' +ValidationKey: '2198460' AutocreateReadme: no AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index c565227..9d3b989 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'GDPuc: Easily Convert GDP Data' -version: 1.0.5 -date-released: '2024-09-09' +version: 1.1.0 +date-released: '2024-09-20' abstract: Convert GDP time series data from one unit to another. All common GDP units are included, i.e. current and constant local currency units, US$ via market exchange rates and international dollars via purchasing power parities. diff --git a/DESCRIPTION b/DESCRIPTION index ccdfcd7..904d26a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: GDPuc Title: Easily Convert GDP Data -Version: 1.0.5 -Date: 2024-09-09 +Version: 1.1.0 +Date: 2024-09-20 Authors@R: person("Johannes", "Koch", , "jokoch@pik-potsdam.de", role = c("aut", "cre")) Description: Convert GDP time series data from one unit to diff --git a/R/check_user_input.R b/R/check_user_input.R index 5a5caba..9186dfc 100644 --- a/R/check_user_input.R +++ b/R/check_user_input.R @@ -47,13 +47,14 @@ check_gdp <- function(gdp) { # Check input parameters 'unit_in' and 'unit_out' check_unit_in_out <- function(unit_in, unit_out) { valid_units <- c( - "current LCU", - "current US\\$MER", - "current Int\\$PPP", - "constant .... LCU", - "constant .... US\\$MER", - "constant .... \u20ac", - "constant .... Int\\$PPP" + "^current LCU$", + "^current US\\$MER$", + "^current Int\\$PPP$", + "^constant .... LCU$", + "^constant .... US\\$MER$", + "^constant .... \u20ac$", + "^constant .... EUR$", + "^constant .... Int\\$PPP$" ) if (!is.character(unit_in) || !any(sapply(valid_units, grepl, unit_in))) { abort("Invalid 'unit_in' argument.") diff --git a/R/convertGDP.R b/R/convertGDP.R index 9bb53dc..1e45edc 100644 --- a/R/convertGDP.R +++ b/R/convertGDP.R @@ -135,7 +135,7 @@ convertGDP <- function(gdp, gsub("_YYYY", "", .) %>% gsub("\\$", "", .) %>% # \u20ac is the ascii code for the € sign - gsub("\u20ac", "EURO", .) + gsub("\u20ac|EUR", "EURO", .) # Get list of function arguments a <- list("gdp" = internal$gdp, "source" = internal$source) %>% diff --git a/tests/testthat/test-05_convertGDP.R b/tests/testthat/test-05_convertGDP.R index 5d55345..73633a5 100644 --- a/tests/testthat/test-05_convertGDP.R +++ b/tests/testthat/test-05_convertGDP.R @@ -214,3 +214,24 @@ test_that("convertSingle", { expect_equal(gdp1_conv$value, gdp2_conv) expect_equal(gdp1_conv, gdp3_conv$result) }) + +test_that("convert euros", { + gdp1_conv <- convertSingle(100, "USA", + unit_in = "constant 2015 LCU", + unit_out = "constant 2017 €") + + gdp2_conv <- convertSingle(100, "USA", + unit_in = "constant 2015 LCU", + unit_out = "constant 2017 EUR") + + gdp3_conv <- convertSingle(100, "DEU", + unit_in = "constant 2010 LCU", + unit_out = "constant 2017 €") + + gdp4_conv <- convertSingle(100, "DEU", + unit_in = "constant 2010 €", + unit_out = "constant 2017 LCU") + + expect_equal(gdp1_conv, gdp2_conv) + expect_equal(gdp3_conv, gdp4_conv) +})