Skip to content

Commit

Permalink
fix uCode space bug and 2-level export bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bluefoxr committed Apr 3, 2024
1 parent d0693c0 commit 3f23750
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <william.becker@bluefoxdata.eu>
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,
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 7 additions & 2 deletions R/new_coin.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)){
Expand Down

0 comments on commit 3f23750

Please sign in to comment.