1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 06:06:12 +01:00

(v1.0.1.9007) small bugfix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-04-14 15:10:09 +02:00
parent 7a6f819232
commit cde65141d9
11 changed files with 32 additions and 38 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 1.0.1.9006 Version: 1.0.1.9007
Date: 2020-04-14 Date: 2020-04-14
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(

View File

@ -1,4 +1,4 @@
# AMR 1.0.1.9006 # AMR 1.0.1.9007
## <small>Last updated: 14-Apr-2020</small> ## <small>Last updated: 14-Apr-2020</small>
### New ### New

44
R/mo.R
View File

@ -178,7 +178,7 @@ as.mo <- function(x,
check_dataset_integrity() check_dataset_integrity()
# start off with replaced language-specific non-ASCII characters with ASCII characters # start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_encoding(x) x <- parse_and_convert(x)
# WHONET: xxx = no growth # WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -263,7 +263,7 @@ exec_as.mo <- function(x,
check_dataset_integrity() check_dataset_integrity()
# start off with replaced language-specific non-ASCII characters with ASCII characters # start off with replaced language-specific non-ASCII characters with ASCII characters
x <- parse_encoding(x) x <- parse_and_convert(x)
# WHONET: xxx = no growth # WHONET: xxx = no growth
x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_ x[tolower(as.character(paste0(x, ""))) %in% c("", "xxx", "na", "nan")] <- NA_character_
@ -277,27 +277,7 @@ exec_as.mo <- function(x,
options(mo_renamed = NULL) options(mo_renamed = NULL)
} }
options(mo_renamed_last_run = NULL) options(mo_renamed_last_run = NULL)
if (NCOL(x) == 2) {
# support tidyverse selection like: df %>% select(colA, colB)
# paste these columns together
x_vector <- vector("character", NROW(x))
for (i in seq_len(NROW(x))) {
x_vector[i] <- paste(pull(x[i, ], 1), pull(x[i, ], 2), sep = " ")
}
x <- x_vector
} else {
if (NCOL(x) > 2) {
stop("`x` can be 2 columns at most", call. = FALSE)
}
x[is.null(x)] <- NA
# support tidyverse selection like: df %>% select(colA)
if (!is.vector(x) & !is.null(dim(x))) {
x <- pull(x, 1)
}
}
uncertainties <- data.frame(uncertainty = integer(0), uncertainties <- data.frame(uncertainty = integer(0),
input = character(0), input = character(0),
fullname = character(0), fullname = character(0),
@ -1977,9 +1957,23 @@ trimws2 <- function(x) {
trimws(gsub("[\\s]+", " ", x, perl = TRUE)) trimws(gsub("[\\s]+", " ", x, perl = TRUE))
} }
parse_encoding <- function(x) { parse_and_convert <- function(x) {
tryCatch({ tryCatch({
x <- unname(unlist(x)) if (!is.null(dim(x))) {
if (NCOL(x) > 2) {
stop("A maximum of two columns is allowed.", call. = FALSE)
} else if (NCOL(x) == 2) {
# support tidyverse selection like: df %>% select(colA, colB)
# paste these columns together
x <- as.data.frame(x, stringsAsFactors = FALSE)
colnames(x) <- c("A", "B")
x <- paste(x$A, x$B)
} else {
# support tidyverse selection like: df %>% select(colA)
x <- as.data.frame(x, stringsAsFactors = FALSE)[[1]]
}
}
x[is.null(x)] <- NA
parsed <- iconv(x, to = "UTF-8") parsed <- iconv(x, to = "UTF-8")
parsed[is.na(parsed) & !is.na(x)] <- iconv(x[is.na(parsed) & !is.na(x)], from = "Latin1", to = "ASCII//TRANSLIT") parsed[is.na(parsed) & !is.na(x)] <- iconv(x[is.na(parsed) & !is.na(x)], from = "Latin1", to = "ASCII//TRANSLIT")
parsed <- gsub('"', "", parsed, fixed = TRUE) parsed <- gsub('"', "", parsed, fixed = TRUE)

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a> <a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>

View File

@ -43,7 +43,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>
@ -229,9 +229,9 @@
<small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small> <small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div> </div>
<div id="amr-1019006" class="section level1"> <div id="amr-1019007" class="section level1">
<h1 class="page-header" data-toc-text="1.0.1.9006"> <h1 class="page-header" data-toc-text="1.0.1.9007">
<a href="#amr-1019006" class="anchor"></a>AMR 1.0.1.9006<small> Unreleased </small> <a href="#amr-1019007" class="anchor"></a>AMR 1.0.1.9007<small> Unreleased </small>
</h1> </h1>
<div id="last-updated-14-apr-2020" class="section level2"> <div id="last-updated-14-apr-2020" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">

View File

@ -10,7 +10,7 @@ articles:
WHONET: WHONET.html WHONET: WHONET.html
benchmarks: benchmarks.html benchmarks: benchmarks.html
resistance_predict: resistance_predict.html resistance_predict: resistance_predict.html
last_built: 2020-04-14T12:12Z last_built: 2020-04-14T12:56Z
urls: urls:
reference: https://msberends.gitlab.io/AMR/reference reference: https://msberends.gitlab.io/AMR/reference
article: https://msberends.gitlab.io/AMR/articles article: https://msberends.gitlab.io/AMR/articles

View File

@ -81,7 +81,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9006</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9007</span>
</span> </span>
</div> </div>