Skip to content

Commit

Permalink
bugfix in datacol detection for data.frames
Browse files Browse the repository at this point in the history
  • Loading branch information
tscheypidi committed Dec 8, 2020
1 parent dd83390 commit 78bd2a7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "magclass: Data Class and Tools for Handling Spatial-Temporal Data",
"version": "5.15.3",
"version": "5.15.4",
"description": "<p>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": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
7 changes: 6 additions & 1 deletion R/as.magpie.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -55,7 +55,7 @@ In case of questions / problems please contact Jan Philipp Dietrich <dietrich@pi
To cite package **magclass** in publications use:

Dietrich J, Bodirsky B, Bonsch M, Humpenoeder F, Bi S, Karstens K (2020). _magclass: Data Class and Tools for Handling
Spatial-Temporal Data_. doi: 10.5281/zenodo.1158580 (URL: https://doi.org/10.5281/zenodo.1158580), R package version 5.15.3,
Spatial-Temporal Data_. doi: 10.5281/zenodo.1158580 (URL: https://doi.org/10.5281/zenodo.1158580), R package version 5.15.4,
<URL: https://github.com/pik-piam/magclass>.

A BibTeX entry for LaTeX users is
Expand All @@ -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},
year = {2020},
note = {R package version 5.15.3},
note = {R package version 5.15.4},
doi = {10.5281/zenodo.1158580},
url = {https://github.com/pik-piam/magclass},
}
Expand Down

0 comments on commit 78bd2a7

Please sign in to comment.