1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 07:02:01 +02:00

check for 2.0

This commit is contained in:
2023-03-12 13:02:37 +01:00
parent 9179e98e12
commit 80cfc503c2
25 changed files with 127 additions and 134 deletions

View File

@ -35,7 +35,7 @@
#'
#' **Important:** Due to how \R works, the [add_custom_microorganisms()] function has to be run in every \R session - added microorganisms are not stored between sessions and are thus lost when \R is exited.
#'
#' There are two ways to automate this process:
#' There are two ways to circumvent this and automate the process of adding microorganisms:
#'
#' **Method 1:** Using the [package option][AMR-options] [`AMR_custom_mo`][AMR-options], which is the preferred method. To use this method:
#'
@ -50,7 +50,7 @@
#'
#' Upon package load, this file will be loaded and run through the [add_custom_microorganisms()] function.
#'
#' **Method 2:** Loading the microorganism directly from your `.Rprofile` file. An important downside is that this requires the `AMR` package to be installed or else this method will fail. To use this method:
#' **Method 2:** Loading the microorganism directly from your `.Rprofile` file. Note that the definitions will be stored in a user-specific \R file, which is a suboptimal workflow. To use this method:
#'
#' 1. Edit the `.Rprofile` file using e.g. `utils::file.edit("~/.Rprofile")`.
#'
@ -64,7 +64,7 @@
#' )
#' ```
#'
#' Use [clear_custom_microorganisms()] to clear the previously added antimicrobials.
#' Use [clear_custom_microorganisms()] to clear the previously added microorganisms.
#' @seealso [add_custom_antimicrobials()] to add custom antimicrobials.
#' @rdname add_custom_microorganisms
#' @export
@ -279,7 +279,7 @@ add_custom_microorganisms <- function(x) {
# clear previous coercions
suppressMessages(mo_reset_session())
AMR_env$MO_lookup <- unique(rbind2(AMR_env$MO_lookup, new_df))
AMR_env$MO_lookup <- unique(rbind_AMR(AMR_env$MO_lookup, new_df))
class(AMR_env$MO_lookup$mo) <- c("mo", "character")
if (nrow(x) <= 3) {
message_("Added ", vector_and(italicise(x$fullname), quotes = FALSE), " to the internal `microorganisms` data set.")
@ -297,6 +297,9 @@ clear_custom_microorganisms <- function() {
AMR_env$MO_lookup <- NULL
add_MO_lookup_to_AMR_env()
# clear previous coercions
suppressMessages(mo_reset_session())
n2 <- nrow(AMR_env$MO_lookup)
AMR_env$custom_mo_codes <- character(0)
AMR_env$mo_previously_coerced <- AMR_env$mo_previously_coerced[which(AMR_env$mo_previously_coerced$mo %in% AMR_env$MO_lookup$mo), , drop = FALSE]