diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml
index b328e2e0..549b23f8 100644
--- a/.github/workflows/check.yaml
+++ b/.github/workflows/check.yaml
@@ -41,8 +41,10 @@ name: R-code-check
jobs:
R-code-check:
runs-on: ${{ matrix.config.os }}
+
+ continue-on-error: ${{ matrix.config.allowfail }}
- name: ${{ matrix.config.os }} (${{ matrix.config.r }})
+ name: ${{ matrix.config.os }} (R-${{ matrix.config.r }})
strategy:
fail-fast: false
@@ -55,11 +57,11 @@ jobs:
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'oldrel'}
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- - {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- # - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
- # - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
+ - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
+ - {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
+ - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
+ - {os: ubuntu-16.04, r: '3.4', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
+ - {os: ubuntu-16.04, r: '3.3', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
diff --git a/DESCRIPTION b/DESCRIPTION
index 31916785..3695623f 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,5 +1,5 @@
Package: AMR
-Version: 1.4.0.9008
+Version: 1.4.0.9009
Date: 2020-10-26
Title: Antimicrobial Resistance Analysis
Authors@R: c(
diff --git a/NEWS.md b/NEWS.md
index 6470ba87..d09d3531 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,4 +1,4 @@
-# AMR 1.4.0.9008
+# AMR 1.4.0.9009
## Last updated: 26 October 2020
### New
diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R
index 20044608..a5a50604 100755
--- a/R/aa_helper_functions.R
+++ b/R/aa_helper_functions.R
@@ -271,8 +271,12 @@ import_fn <- function(name, pkg, error_on_fail = TRUE) {
# - ignores formatted text while wrapping
# - adds indentation dependent on the type of message (like NOTE)
# - add additional formatting functions like blue or bold text
-message_ <- function(..., appendLF = TRUE, add_fn = list(font_blue)) {
+message_ <- function(..., appendLF = TRUE, add_fn = list(font_blue), as_note = TRUE) {
msg <- paste0(c(...), collapse = "")
+
+ if (isTRUE(as_note)) {
+ msg <- paste0("NOTE: ", gsub("note:? ?", "", msg, ignore.case = TRUE))
+ }
# we need to correct for already applied style, that adds text like "\033[31m\"
msg_stripped <- font_stripstyle(msg)
diff --git a/R/mo.R b/R/mo.R
index daeb411e..d5ac604f 100755
--- a/R/mo.R
+++ b/R/mo.R
@@ -205,7 +205,6 @@ as.mo <- function(x,
& all(x %in% reference_df[, 1][[1]])) {
# has valid own reference_df
- # (data.table not faster here)
reference_df <- reference_df %pm>% pm_filter(!is.na(mo))
# keep only first two columns, second must be mo
if (colnames(reference_df)[1] == "mo") {
@@ -213,6 +212,9 @@ as.mo <- function(x,
} else {
reference_df <- reference_df[, c(1, 2)]
}
+ # some microbial codes might be old
+ reference_df[, 1] <- as.mo(reference_df[, 1, drop = TRUE])
+
colnames(reference_df)[1] <- "x"
# remove factors, just keep characters
suppressWarnings(
@@ -221,9 +223,7 @@ as.mo <- function(x,
suppressWarnings(
y <- data.frame(x = x, stringsAsFactors = FALSE) %pm>%
pm_left_join(reference_df, by = "x") %pm>%
- pm_pull("mo") %pm>%
- # run as.mo() for when using old microbial codes
- as.mo()
+ pm_pull("mo")
)
} else if (all(x[!is.na(x)] %in% MO_lookup$mo)
@@ -415,7 +415,7 @@ exec_as.mo <- function(x,
reference_df <- reference_df[, c(1, 2)]
}
# some microbial codes might be old
- reference_df$mo <- as.mo(reference_df$mo)
+ reference_df[, 1] <- as.mo(reference_df[, 1, drop = TRUE])
colnames(reference_df)[1] <- "x"
# remove factors, just keep characters
@@ -1438,7 +1438,7 @@ exec_as.mo <- function(x,
}
msg <- paste0("Translation to ", nr2char(length(uncertainties$input)), " microorganism", plural[1],
" ", plural[3], " guessed with uncertainty. Use mo_uncertainties() to review ", plural[2], ".")
- message(font_red(msg))
+ message_(msg)
}
# Becker ----
diff --git a/docs/404.html b/docs/404.html
index 2b059ce4..9e1ff30d 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
NEWS.md
-
Making this package independent of especially the tidyverse (e.g. packages dplyr
and tidyr
) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.
Negative effects of this change are:
freq()
that was borrowed from the cleaner
package was removed. Use cleaner::freq()
, or run library("cleaner")
before you use freq()
.freq()
that was borrowed from the cleaner
package was removed. Use cleaner::freq()
, or run library("cleaner")
before you use freq()
.mo
or rsi
in a tibble will no longer be in colour and printing rsi
in a tibble will show the class <ord>
, not <rsi>
anymore. This is purely a visual effect.mo_*
family (like mo_name()
and mo_gramstain()
) are noticeably slower when running on hundreds of thousands of rows.mo
and ab
now both also inherit class character
, to support any data transformation. This change invalidates code that checks for class length == 1.This is important, because a value like "testvalue"
could never be understood by e.g. mo_name()
, although the class would suggest a valid microbial code.
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Function freq()
has moved to a new package, clean
(CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq()
function still works, since it is re-exported from the clean
package (which will be installed automatically upon updating this AMR
package).
Renamed data set septic_patients
to example_isolates
age()
function gained a new parameter exact
to determine ages with decimalsguess_mo()
, guess_atc()
, EUCAST_rules()
, interpretive_reading()
, rsi()
freq()
):
+freq()
):
speed improvement for microbial IDs
fixed factor level names for R Markdown
support for boxplots:
age_groups()
, to let groups of fives and tens end with 100+ instead of 120+freq()
for when all values are NA
+freq()
for when all values are NA
first_isolate()
for when dates are missingguess_ab_col()
@@ -1317,7 +1317,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
freq()
function):
+freq()
function):
Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:
@@ -1326,15 +1326,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo))Header info is now available as a list, with the header
function
The parameter header
is now set to TRUE
at default, even for markdown
Using portion_*
functions now throws a warning when total available isolate is below parameter minimum
Functions as.mo
, as.rsi
, as.mic
, as.atc
and freq
will not set package name as attribute anymore
Frequency tables - freq()
:
Frequency tables - freq()
:
Support for grouping variables, test with:
+ freq(gender)Support for (un)selecting columns:
Check for hms::is.hms
Check for hms::is.hms
Now prints in markdown at default in non-interactive sessions
No longer adds the factor level column and sorts factors on count again
Support for class difftime
Removed diacritics from all authors (columns microorganisms$ref
and microorganisms.old$ref
) to comply with CRAN policy to only allow ASCII characters
Fix for mo_property
not working properly
Fix for eucast_rules
where some Streptococci would become ceftazidime R in EUCAST rule 4.5
Support for named vectors of class mo
, useful for top_freq()
Support for named vectors of class mo
, useful for top_freq()
ggplot_rsi
and scale_y_percent
have breaks
parameter
AI improvements for as.mo
:
Support for types (classes) list and matrix for freq
For lists, subsetting is possible:
my_list = list(age = septic_patients$age, gender = septic_patients$gender) -my_list %>% freq(age) -my_list %>% freq(gender)
rsi
(antimicrobial resistance) to use as inputtable
to use as input: freq(table(x, y))
+table
to use as input: freq(table(x, y))
hist
and plot
to use a frequency table as input: hist(freq(df$age))
as.vector
, as.data.frame
, as_tibble
and format
freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
+freq(mydata, mycolumn)
is the same as mydata %>% freq(mycolumn)
top_freq
function to return the top/below n items as vector