diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f840204..234b6383 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,7 +93,6 @@ R-release: allow_failure: true script: - Rscript -e 'sessionInfo()' - - Rscript -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' # install missing and outdated packages - Rscript -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE, install_pkgdown = TRUE, install_lintr = TRUE)' # remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file @@ -102,6 +101,8 @@ R-release: # build package - R CMD build . --no-build-vignettes --no-manual - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1) + - Rscript -e 'devtools::install_local("${PKG_FILE_NAME}")' + - Rscript -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' - Rscript -e 'Sys.setenv(NOT_CRAN = "true")' - R CMD check "${PKG_FILE_NAME}" --no-build-vignettes --no-manual --as-cran artifacts: @@ -121,7 +122,6 @@ R-devel: allow_failure: true script: - Rscriptdevel -e 'sessionInfo()' - - Rscriptdevel -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' # install missing and outdated packages - Rscriptdevel -e 'source(".gitlab-ci.R"); gl_update_pkg_all(repos = "https://cran.rstudio.com", quiet = TRUE)' # remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file @@ -130,6 +130,8 @@ R-devel: # build package - Rdevel CMD build . --no-build-vignettes --no-manual - PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1) + - Rscript -e 'devtools::install_local("${PKG_FILE_NAME}")' + - Rscript -e 'AMR::eucast_rules(AMR::example_isolates_unclean, info = TRUE)' - Rscript -e 'Sys.setenv(NOT_CRAN = "true")' - Rdevel CMD check "${PKG_FILE_NAME}" --no-build-vignettes --no-manual --as-cran artifacts: diff --git a/DESCRIPTION b/DESCRIPTION index 9ec90077..3329ab74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.1.0.9008 -Date: 2020-05-17 +Version: 1.1.0.9009 +Date: 2020-05-18 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 57a65e32..522d7c4a 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.1.0.9008 -## Last updated: 17-May-2020 +# AMR 1.1.0.9009 +## Last updated: 18-May-2020 ### Breaking * Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()` diff --git a/R/atc_online.R b/R/atc_online.R index 0b056755..00330f27 100644 --- a/R/atc_online.R +++ b/R/atc_online.R @@ -132,7 +132,7 @@ atc_online_property <- function(atc_code, for (i in seq_len(length(atc_code))) { - progress$tick()$print() + progress$tick() atc_url <- sub("%s", atc_code[i], url, fixed = TRUE) diff --git a/R/first_isolate.R b/R/first_isolate.R index 3d21899b..1c61cc0c 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -46,12 +46,9 @@ #' #' All isolates with a microbial ID of `NA` will be excluded as first isolate. #' -#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to: +#' The functions [filter_first_isolate()] and [filter_first_weighted_isolate()] are helper functions to quickly filter on first isolates. The function [filter_first_isolate()] is essentially equal to one of: #' ``` -#' x %>% -#' mutate(only_firsts = first_isolate(x, ...)) %>% -#' filter(only_firsts == TRUE) %>% -#' select(-only_firsts) +#' x %>% filter(first_isolate(., ...)) #' ``` #' The function [filter_first_weighted_isolate()] is essentially equal to: #' ``` @@ -60,7 +57,7 @@ #' mutate(only_weighted_firsts = first_isolate(x, #' col_keyantibiotics = "keyab", ...)) %>% #' filter(only_weighted_firsts == TRUE) %>% -#' select(-only_weighted_firsts) +#' select(-only_weighted_firsts, -keyab) #' ``` #' @section Key antibiotics: #' There are two ways to determine whether isolates can be included as first *weighted* isolates which will give generally the same results: @@ -451,7 +448,7 @@ filter_first_isolate <- function(x, col_patient_id = NULL, col_mo = NULL, ...) { - filter(x, first_isolate(x = x, + subset(x, first_isolate(x = x, col_date = col_date, col_patient_id = col_patient_id, col_mo = col_mo, @@ -466,15 +463,23 @@ filter_first_weighted_isolate <- function(x, col_mo = NULL, col_keyantibiotics = NULL, ...) { - tbl_keyab <- x %>% - mutate(keyab = suppressMessages(key_antibiotics(., - col_mo = col_mo, - ...))) %>% - mutate(firsts = first_isolate(., - col_date = col_date, - col_patient_id = col_patient_id, - col_mo = col_mo, - col_keyantibiotics = "keyab", - ...)) - x[which(tbl_keyab$firsts == TRUE), ] + y <- x + if (is.null(col_keyantibiotics)) { + # first try to look for it + col_keyantibiotics <- search_type_in_df(x = x, type = "keyantibiotics") + # still NULL? Then create it since we are calling filter_first_WEIGHTED_isolate() + if (is.null(col_keyantibiotics)) { + y$keyab <- suppressMessages(key_antibiotics(x, + col_mo = col_mo, + ...)) + col_keyantibiotics <- "keyab" + } + } + + subset(x, first_isolate(x = y, + col_date = col_date, + col_patient_id = col_patient_id, + col_mo = col_mo, + col_keyantibiotics = col_keyantibiotics, + ...)) } diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 9dc7c233..9bfc4770 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -214,11 +214,9 @@ key_antibiotics <- function(x, warning("only using ", length(gram_negative), " different antibiotics as key antibiotics for Gram-negatives. See ?key_antibiotics.", call. = FALSE) } - # join to microorganisms data set - x <- x %>% as.data.frame(stringsAsFactors = FALSE) + x <- as.data.frame(x, stringsAsFactors = FALSE) x[, col_mo] <- as.mo(x[, col_mo, drop = TRUE]) x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL) - x$key_ab <- NA_character_ # Gram + diff --git a/_pkgdown.yml b/_pkgdown.yml index 37c5c086..7ae14e2d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -96,7 +96,6 @@ reference: - "`eucast_rules`" - "`guess_ab_col`" - "`mo_source`" - - "`read.4D`" - title: "Enhancing your data" desc: > Functions to add new data to your existing data, such as the determination diff --git a/docs/404.html b/docs/404.html index 34dd5f5b..51e5383b 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 410fa440..3e6c41d9 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 48eb7097..bbc4833d 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ @@ -186,7 +186,7 @@vignettes/AMR.Rmd
AMR.Rmd
Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 15 April 2020.
+Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 18 May 2020.
Conducting antimicrobial resistance analysis unfortunately requires in-depth knowledge from different scientific fields, which makes it hard to do right. At least, it requires: