diff --git a/.buildlibrary b/.buildlibrary index 460932c8..36c78f99 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '95861259' +ValidationKey: '95885016' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/.zenodo.json b/.zenodo.json index bfa08054..fe41c937 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "magclass: Data Class and Tools for Handling Spatial-Temporal Data", - "version": "5.15.3", + "version": "5.15.4", "description": "
Data class for increased interoperability working with spatial-\n temporal data together with corresponding functions and methods (conversions,\n basic calculations and basic data manipulation). The class distinguishes\n between spatial, temporal and other dimensions to facilitate the development\n and interoperability of tools build for it. Additional features are name-based\n addressing of data and internal consistency checks (e.g. checking for the right\n data order in calculations).<\/p>",
"creators": [
{
diff --git a/DESCRIPTION b/DESCRIPTION
index e46ad3a8..3d6d6c52 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Package: magclass
Type: Package
Title: Data Class and Tools for Handling Spatial-Temporal Data
-Version: 5.15.3
-Date: 2020-12-07
+Version: 5.15.4
+Date: 2020-12-08
Authors@R: c(person("Jan Philipp", "Dietrich", email = "dietrich@pik-potsdam.de", role = c("aut","cre")),
person("Benjamin Leon", "Bodirsky", email = "bodirsky@pik-potsdam.de", role = "aut"),
person("Markus", "Bonsch", role = "aut"),
diff --git a/R/as.magpie.R b/R/as.magpie.R
index 433272fc..f312bd16 100644
--- a/R/as.magpie.R
+++ b/R/as.magpie.R
@@ -193,8 +193,13 @@ setMethod("as.magpie",
if(tidy) return(tidy2magpie(x,...))
if(dim(x)[1]==0) return(copy.attributes(x,new.magpie(NULL)))
if(is.null(datacol)) {
+ is.numericlike <- function(x) {
+ .tmp <- function(x) return(all(!is.na(suppressWarnings(as.numeric(x[!is.na(x)])))))
+ if(isFALSE(.tmp(x[1]))) return(FALSE)
+ return(.tmp(x))
+ }
for(i in dim(x)[2]:1) {
- if(all(!is.na(suppressWarnings(as.numeric(x[!is.na(x[,i]),i])))) & !is.temporal(x[,i]) & !is.factor(x[,i])) {
+ if(!is.factor(x[[i]]) && is.numericlike(x[[i]]) && !is.temporal(x[[i]])) {
datacol <- i
} else {
break
diff --git a/README.md b/README.md
index 40e8395a..0e75e862 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Data Class and Tools for Handling Spatial-Temporal Data
-R package **magclass**, version **5.15.3**
+R package **magclass**, version **5.15.4**
[![Travis build status](https://travis-ci.com/pik-piam/magclass.svg?branch=master)](https://travis-ci.com/pik-piam/magclass) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158580.svg)](https://doi.org/10.5281/zenodo.1158580) [![codecov](https://codecov.io/gh/pik-piam/magclass/branch/master/graph/badge.svg)](https://codecov.io/gh/pik-piam/magclass)
@@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich