From 3f237509ee50d5817279b525adddddcf1d6d43a0 Mon Sep 17 00:00:00 2001 From: bluefoxr Date: Wed, 3 Apr 2024 16:11:53 +0200 Subject: [PATCH] fix uCode space bug and 2-level export bug --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ R/new_coin.R | 9 +++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d35f75b1..ce16ab5e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: COINr Type: Package Title: Composite Indicator Construction and Analysis -Version: 1.1.12 +Version: 1.1.13 Maintainer: William Becker Description: A comprehensive high-level package, for composite indicator construction and analysis. It is a "development environment" for composite indicators and scoreboards, which includes utilities for construction (indicator selection, denomination, imputation, diff --git a/NEWS.md b/NEWS.md index fe296de0..d743db8f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# COINr 1.1.13 + +- Minor bug fixes: spaces in uCodes, issue exporting 2-level composite indicators to Excel + # COINr 1.1.12 - Enable custom operations on coins and purses: new generic `Custom()` with methods diff --git a/R/new_coin.R b/R/new_coin.R index 2d3aaf85..d372a491 100644 --- a/R/new_coin.R +++ b/R/new_coin.R @@ -373,6 +373,11 @@ check_iData <- function(iData, quietly = FALSE){ if(!is.character(iData$uCode)){ stop("uCode is required to be a character vector.") } + # should not contain spaces + spaces <- grepl(" ", iData$uCode) + if(any(spaces)){ + stop("uCode contains entries with spaces - this is not allowed.") + } # SPECIAL COLS ------------------------------------------------------------ # Special cols are those that are not REQUIRED but defined in iMeta @@ -775,14 +780,14 @@ get_lineage <- function(iMeta, level_names = NULL){ if(maxlev == 1){ wideS <- wideS["iCode"] warning("Only one level is defined in iMeta. This is not normally expected in a composite indicator, and some functions may not work as expected.", call. = FALSE) - } else { + } else if (maxlev > 2) { # successively add columns by looking up parent codes of last col for(ii in 2:(maxlev-1)){ wideS <- cbind(wideS, longS$Parent[match(wideS[[ii]], longS$iCode)]) } } - + # NOTE: if maxlev == 2, nothing needs to be done # rename columns if(is.null(level_names)){