diff --git a/NEWS.md b/NEWS.md index b01e39d4..210f2071 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,6 @@ # 0.2.0.90xx (development version) +**Published on CRAN: (unpublished)** + #### New * **BREAKING**: `rsi_df` was removed in favour of new functions `R`, `IR`, `SI` and `S` to selectively calculate resistance or susceptibility. These functions use **hybrid evaluation**, which means that calculations are not done in R directly but rather in C++ using the `Rcpp` package, making them 20 to 30 times faster. The function `rsi` still works, but is deprecated. * **BREAKING**: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call *key antibiotics*) to include more first isolates (afterwards called first *weighted* isolates) are now as follows: @@ -53,6 +55,8 @@ * Unit testing for R 3.0 and the latest available release: https://travis-ci.org/msberends/AMR # 0.2.0 (latest stable version) +**Published on CRAN: 2018-05-03** + #### New * Full support for Windows, Linux and macOS * Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies) @@ -88,6 +92,8 @@ * Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R) # 0.1.1 +**Published on CRAN: 2018-03-14** + * `EUCAST_rules` applies for amoxicillin even if ampicillin is missing * Edited column names to comply with GLIMS, the laboratory information system * Added more valid MIC values @@ -95,4 +101,6 @@ * Added barplots for `rsi` and `mic` classes # 0.1.0 +**Published on CRAN: 2018-02-22** + * First submission to CRAN. diff --git a/R/eucast.R b/R/eucast.R index 3be56551..15e5006c 100755 --- a/R/eucast.R +++ b/R/eucast.R @@ -275,7 +275,7 @@ EUCAST_rules <- function(tbl, # join to microorganisms data set if (!tbl %>% pull(col_bactid) %>% is.bactid()) { - # warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.") + warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.") } tbl <- tbl %>% left_join_microorganisms(by = col_bactid, suffix = c("_tempmicroorganisms", "")) diff --git a/R/first_isolate.R b/R/first_isolate.R index 6ba66831..b563f35b 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -171,7 +171,7 @@ first_isolate <- function(tbl, if (!is.na(col_bactid)) { if (!tbl %>% pull(col_bactid) %>% is.bactid()) { - # warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.") + warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.") } # join to microorganisms data set tbl <- tbl %>% left_join_microorganisms(by = col_bactid) diff --git a/tests/testthat/test-eucast.R b/tests/testthat/test-eucast.R index 47fe5108..fd9cc69e 100755 --- a/tests/testthat/test-eucast.R +++ b/tests/testthat/test-eucast.R @@ -16,7 +16,8 @@ test_that("EUCAST rules work", { "ENTAER"), # Enterobacter aerogenes amox = "R", # Amoxicillin stringsAsFactors = FALSE) - expect_identical(EUCAST_rules(a, info = FALSE), b) + expect_warning(EUCAST_rules(a, info = FALSE)) + expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b) expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b) a <- data.frame(bactid = @@ -29,7 +30,7 @@ test_that("EUCAST rules work", { "STCGRA"), # Streptococcus pyognenes (Lancefield Group A) coli = "R", # Colistin stringsAsFactors = FALSE) - expect_equal(EUCAST_rules(a, info = FALSE), b) + expect_equal(suppressWarnings(EUCAST_rules(a, info = FALSE)), b) }) test_that("MO properties work", { diff --git a/tests/testthat/test-freq.R b/tests/testthat/test-freq.R index c81fcb14..fbb4f568 100755 --- a/tests/testthat/test-freq.R +++ b/tests/testthat/test-freq.R @@ -66,5 +66,20 @@ test_that("frequency table works", { pull(age) %>% sort()) + # check format + expect_identical(septic_patients %>% + freq(age) %>% + format() %>% + apply(2, class) %>% + unname(), + rep("character", 5)) + + # check tibble + expect_identical(septic_patients %>% + freq(age) %>% + as_tibble() %>% + class() %>% + .[1], + "tbl_df") }) diff --git a/tests/testthat/test-resistance.R b/tests/testthat/test-resistance.R index 14d0c5b9..65c0d209 100755 --- a/tests/testthat/test-resistance.R +++ b/tests/testthat/test-resistance.R @@ -43,6 +43,25 @@ test_that("resistance works", { expect_warning(susceptibility(as.character(septic_patients$amcl, septic_patients$gent))) + + # check for errors + expect_error(IR(septic_patients %>% select(amox, amcl))) + expect_error(IR("test", minimum = "test")) + expect_error(IR("test", as_percent = "test")) + expect_error(S("test", minimum = "test")) + expect_error(S("test", as_percent = "test")) + expect_error(S(septic_patients %>% select(amox, amcl))) + expect_error(S("R", septic_patients %>% select(amox, amcl))) + + # check too low amount of isolates + expect_identical(IR(septic_patients$amox, minimum = nrow(septic_patients) + 1), + NA) + expect_identical(S(septic_patients$amox, minimum = nrow(septic_patients) + 1), + NA) + + # warning for speed loss + expect_warning(S(septic_patients$amcl, as.character(septic_patients$gent))) + }) test_that("old rsi works", { @@ -129,4 +148,9 @@ test_that("prediction of rsi works", { col_ab = "amox", col_date = "NOT EXISTING COLUMN", info = TRUE)) + # almost all E. coli are mero S in the Netherlands :) + expect_error(resistance_predict(tbl = filter(septic_patients, bactid == "ESCCOL"), + col_ab = "mero", + col_date = "date", + info = TRUE)) })