diff --git a/DESCRIPTION b/DESCRIPTION index 725712b38..9e1b565f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9257 +Version: 2.1.1.9258 Date: 2025-04-27 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 37c276e3c..d59a44098 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9257 +# AMR 2.1.1.9258 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://amr-for-r.org/#get-this-package).)* @@ -47,7 +47,7 @@ This package now supports not only tools for AMR data analysis in clinical setti ## Changed * SIR interpretation - * Support for parallel computing using the `parallel` package (part of base R). Use `as.sir(your_data, parallel = TRUE)` to run SIR interpretation using multiple cores. + * Support for parallel computing to greatly improve speed using the `parallel` package (part of base R). Use `as.sir(your_data, parallel = TRUE)` to run SIR interpretation using multiple cores. * It is now possible to use column names for arguments `guideline`, `ab`, `mo`, and `uti`: `as.sir(..., ab = "column1", mo = "column2", uti = "column3")`. This greatly improves the flexibility for users. * Users can now set their own criteria (using regular expressions) as to what should be considered S, I, R, SDD, and NI. * To get quantitative values, `as.double()` on a `sir` object will return 1 for S, 2 for SDD/I, and 3 for R (NI will become `NA`). Other functions using `sir` classes (e.g., `summary()`) are updated to reflect the change to contain NI and SDD. diff --git a/R/sir.R b/R/sir.R index 8fdb20267..3a01951e9 100755 --- a/R/sir.R +++ b/R/sir.R @@ -680,7 +680,7 @@ as.sir.disk <- function(x, } #' @rdname as.sir -#' @param parallel A [logical] to indicate if parallel computing must be used, defaults to `FALSE`. This requires no additional packages, as the used `parallel` package is part of base \R. +#' @param parallel A [logical] to indicate if parallel computing must be used, defaults to `FALSE`. This requires no additional packages, as the used `parallel` package is part of base \R. On Windows and on \R < 4.0.0 [parallel::parLapply()] will be used; in all other cases the most efficient [parallel::mclapply()] will be used. #' @param max_cores Maximum number of cores to use if `parallel = TRUE`. Use a negative value to subtract that number from the available number of cores, e.g. a value of `-2` on an 8-core machine means that at most 6 cores will be used. Defaults to `-1`. There will never be used more cores than variables to analyse. The available number of cores are detected using [parallelly::availableCores()] if that package is installed, and base \R's [parallel::detectCores()] otherwise. #' @export as.sir.data.frame <- function(x, @@ -955,7 +955,7 @@ as.sir.data.frame <- function(x, message() message_("Running in parallel mode using ", n_cores, " out of ", get_n_cores(Inf), " cores, on columns ", vector_and(font_bold(ab_cols, collapse = NULL), quotes = "'", sort = FALSE), "...", as_note = FALSE, appendLF = FALSE, add_fn = font_red) } - if (.Platform$OS.type == "windows") { + if (.Platform$OS.type == "windows" || getRversion() < "4.0.0") { cl <- parallel::makeCluster(n_cores, type = "PSOCK") on.exit(parallel::stopCluster(cl), add = TRUE) parallel::clusterExport(cl, varlist = c( diff --git a/R/sysdata.rda b/R/sysdata.rda index 84eb2d48c..bdf03b915 100755 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/man/as.sir.Rd b/man/as.sir.Rd index fad1c5beb..e2c169412 100644 --- a/man/as.sir.Rd +++ b/man/as.sir.Rd @@ -138,7 +138,7 @@ The default \code{"standard"} setting ensures cautious handling of uncertain val \item{col_mo}{Column name of the names or codes of the microorganisms (see \code{\link[=as.mo]{as.mo()}}) - the default is the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} -\item{parallel}{A \link{logical} to indicate if parallel computing must be used, defaults to \code{FALSE}. This requires no additional packages, as the used \code{parallel} package is part of base \R.} +\item{parallel}{A \link{logical} to indicate if parallel computing must be used, defaults to \code{FALSE}. This requires no additional packages, as the used \code{parallel} package is part of base \R. On Windows and on \R < 4.0.0 \code{\link[parallel:clusterApply]{parallel::parLapply()}} will be used; in all other cases the most efficient \code{\link[parallel:mclapply]{parallel::mclapply()}} will be used.} \item{max_cores}{Maximum number of cores to use if \code{parallel = TRUE}. Use a negative value to subtract that number from the available number of cores, e.g. a value of \code{-2} on an 8-core machine means that at most 6 cores will be used. Defaults to \code{-1}. There will never be used more cores than variables to analyse. The available number of cores are detected using \code{\link[parallelly:availableCores]{parallelly::availableCores()}} if that package is installed, and base \R's \code{\link[parallel:detectCores]{parallel::detectCores()}} otherwise.}