diff --git a/.buildlibrary b/.buildlibrary index acda807..22e0c9b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '122203328' +ValidationKey: '1222642778871' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 0b185c8..47041c4 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: 'magclass: Data Class and Tools for Handling Spatial-Temporal Data' -version: 6.15.2 -date-released: '2024-05-21' +version: 6.15.2.9001 +date-released: '2024-05-28' abstract: Data class for increased interoperability working with spatial-temporal data together with corresponding functions and methods (conversions, basic calculations and basic data manipulation). The class distinguishes between spatial, temporal diff --git a/DESCRIPTION b/DESCRIPTION index 824c547..8156dc5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: magclass Title: Data Class and Tools for Handling Spatial-Temporal Data -Version: 6.15.2 -Date: 2024-05-21 +Version: 6.15.2.9001 +Date: 2024-05-28 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", comment = c(affiliation = "Potsdam Institute for Climate Impact Research", ORCID = "0000-0002-4309-6431"), role = c("aut", "cre")), diff --git a/R/mbind.R b/R/mbind.R index d19c1d7..dad96b0 100644 --- a/R/mbind.R +++ b/R/mbind.R @@ -76,9 +76,49 @@ mbind <- function(...) { #nolint " data objects! Cannot handle this case!") } - if (diffspat && difftemp) stop("Cannot handle objects! Spatial as well as temporal dimensions differ!") - if (difftemp && diffdata) stop("Cannot handle objects! Data as well as temporal dimensions differ!") - if (diffdata && diffspat) stop("Cannot handle objects! Data as well as spatial dimensions differ!") + diffall <- c("spatial" = diffspat, "temporal" = difftemp, "data" = diffdata) + if (1 < sum(diffall)) { + msg <- c("Cannot handle objects!", + paste(paste(head(names(diffall)[diffall], n = -1), + collapse = ", "), + tail(names(diffall)[diffall], n = 1), + sep = " as well as "), + "dimensions differ!") + substr(msg[2], 1, 1) <- toupper(substr(msg[2], 1, 1)) + + msg <- paste(c(paste(msg, collapse = " "), + " Differences from first mbind() input:", + vapply(which(diffall), function(i) { + + lhs <- getItems(inputs[[1]], dim = i) + rhs <- Reduce(union, lapply(tail(inputs, n = -1), + getItems, dim = i)) + + # do a kind of three-way diff + diff <- list("missing" = setdiff(lhs, rhs), + " having" = intersect(lhs, rhs), + " adding" = setdiff(rhs, lhs)) + + diff <- lapply(diff, function(x) { + if (4 < length(x)) { + # shorten to four elements, like str() does + x <- c(paste0("`", x[1:4], "`"), "...") + } else if (0 < length(x)) { + x <- paste0("`", x, "`") + } + return(paste(x, collapse = ", ")) + }) + + # paste diff + d <- nzchar(diff) + paste(c(paste0(" ", names(diffall)[i], ":"), + paste(paste0(" ", names(diff)[d], ":"), + diff[d])), + collapse = "\n") + }, character(1))), collapse = "\n") + stop(msg) + } + if (difftemp) { if (length(years) != length(unique(years))) stop("Some years occur more than once!", " Cannot handle this case!") diff --git a/README.md b/README.md index c125de9..1a838e6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Data Class and Tools for Handling Spatial-Temporal Data -R package **magclass**, version **6.15.2** +R package **magclass**, version **6.15.2.9001** [![CRAN status](https://www.r-pkg.org/badges/version/magclass)](https://cran.r-project.org/package=magclass) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158580.svg)](https://doi.org/10.5281/zenodo.1158580) [![R build status](https://github.com/pik-piam/magclass/workflows/check/badge.svg)](https://github.com/pik-piam/magclass/actions) [![codecov](https://codecov.io/gh/pik-piam/magclass/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magclass) [![r-universe](https://pik-piam.r-universe.dev/badges/magclass)](https://pik-piam.r-universe.dev/builds) @@ -56,7 +56,7 @@ In case of questions / problems please contact Jan Philipp Dietrich . +Dietrich J, Bodirsky B, Bonsch M, Humpenoeder F, Bi S, Karstens K, Leip D, Sauer P (2024). _magclass: Data Class and Tools for Handling Spatial-Temporal Data_. doi:10.5281/zenodo.1158580 , R package version 6.15.2.9001, . A BibTeX entry for LaTeX users is @@ -65,7 +65,7 @@ A BibTeX entry for LaTeX users is title = {magclass: Data Class and Tools for Handling Spatial-Temporal Data}, author = {Jan Philipp Dietrich and Benjamin Leon Bodirsky and Markus Bonsch and Florian Humpenoeder and Stephen Bi and Kristine Karstens and Debbora Leip and Pascal Sauer}, year = {2024}, - note = {R package version 6.15.2}, + note = {R package version 6.15.2.9001}, doi = {10.5281/zenodo.1158580}, url = {https://github.com/pik-piam/magclass}, }