From 77d9cf1936824ce47632834d1a9c42fec8a4831f Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Fri, 30 Dec 2022 13:02:37 +0100 Subject: [PATCH] documentation --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/mean_amr_distance.R | 12 ++++++------ man/g.test.Rd | 2 +- man/mean_amr_distance.Rd | 15 +++------------ 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 14bc13d9..d159ca81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.8.2.9075 +Version: 1.8.2.9076 Date: 2022-12-30 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 4f89e136..d204913d 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# 1.8.2.9075 +# 1.8.2.9076 *(this beta version will eventually become v2.0! We're happy to reach a new major milestone soon!)* diff --git a/R/mean_amr_distance.R b/R/mean_amr_distance.R index fe8defc3..e2493a83 100644 --- a/R/mean_amr_distance.R +++ b/R/mean_amr_distance.R @@ -27,11 +27,11 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -#' Mean AMR Distance +#' Calculate the Mean AMR Distance #' -#' This function calculates a normalised mean for antimicrobial resistance between multiple observations. +#' Calculates a normalised mean for antimicrobial resistance between multiple observations, to help to identify similar isolates without comparing antibiograms by hand. #' @param x a vector of class [rsi][as.rsi()], [rsi][as.rsi()] or [rsi][as.rsi()], or a [data.frame] containing columns of any of these classes -#' @param ... variables to select (supports tidy selection such as `column1:column4` and [`where(is.mic)`][tidyselect::language]), and can thus also be [antibiotic selectors][ab_selector()] +#' @param ... variables to select (supports [tidyselect language][tidyselect::language] such as `column1:column4` and `where(is.mic)`, and can thus also be [antibiotic selectors][ab_selector()] #' @param combine_SI a [logical] to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to `TRUE` #' @details The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to [Z scores](https://en.wikipedia.org/wiki/Standard_score) (the number of standard deviations from the mean). #' @@ -83,20 +83,20 @@ mean_amr_distance <- function(x, ...) { UseMethod("mean_amr_distance") } -#' @rdname mean_amr_distance +#' @noRd #' @export mean_amr_distance.default <- function(x, ...) { x <- as.double(x) (x - mean(x, na.rm = TRUE)) / stats::sd(x, na.rm = TRUE) } -#' @rdname mean_amr_distance +#' @noRd #' @export mean_amr_distance.mic <- function(x, ...) { mean_amr_distance(log2(x)) } -#' @rdname mean_amr_distance +#' @noRd #' @export mean_amr_distance.disk <- function(x, ...) { mean_amr_distance(as.double(x)) diff --git a/man/g.test.Rd b/man/g.test.Rd index 5081cc04..940bc86e 100644 --- a/man/g.test.Rd +++ b/man/g.test.Rd @@ -21,7 +21,7 @@ g.test(x, y = NULL, p = rep(1/length(x), length(x)), rescale.p = FALSE) \item{y}{a numeric vector; ignored if \code{x} is a matrix. If \code{x} is a factor, \code{y} should be a factor of the same length.} -\item{p}{a vector of probabilities of the same length as \code{x}. +\item{p}{a vector of probabilities of the same length of \code{x}. An error is given if any entry of \code{p} is negative.} \item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled diff --git a/man/mean_amr_distance.Rd b/man/mean_amr_distance.Rd index 5b65b2e8..5e6f9429 100644 --- a/man/mean_amr_distance.Rd +++ b/man/mean_amr_distance.Rd @@ -2,22 +2,13 @@ % Please edit documentation in R/mean_amr_distance.R \name{mean_amr_distance} \alias{mean_amr_distance} -\alias{mean_amr_distance.default} -\alias{mean_amr_distance.mic} -\alias{mean_amr_distance.disk} \alias{mean_amr_distance.rsi} \alias{mean_amr_distance.data.frame} \alias{amr_distance_from_row} -\title{Mean AMR Distance} +\title{Calculate the Mean AMR Distance} \usage{ mean_amr_distance(x, ...) -\method{mean_amr_distance}{default}(x, ...) - -\method{mean_amr_distance}{mic}(x, ...) - -\method{mean_amr_distance}{disk}(x, ...) - \method{mean_amr_distance}{rsi}(x, ..., combine_SI = TRUE) \method{mean_amr_distance}{data.frame}(x, ..., combine_SI = TRUE) @@ -27,7 +18,7 @@ amr_distance_from_row(amr_distance, row) \arguments{ \item{x}{a vector of class \link[=as.rsi]{rsi}, \link[=as.rsi]{rsi} or \link[=as.rsi]{rsi}, or a \link{data.frame} containing columns of any of these classes} -\item{...}{variables to select (supports tidy selection such as \code{column1:column4} and \code{\link[tidyselect:language]{where(is.mic)}}), and can thus also be \link[=ab_selector]{antibiotic selectors}} +\item{...}{variables to select (supports \link[tidyselect:language]{tidyselect language} such as \code{column1:column4} and \code{where(is.mic)}, and can thus also be \link[=ab_selector]{antibiotic selectors}} \item{combine_SI}{a \link{logical} to indicate whether all values of S and I must be merged into one, so the input only consists of S+I vs. R (susceptible vs. resistant), defaults to \code{TRUE}} @@ -36,7 +27,7 @@ amr_distance_from_row(amr_distance, row) \item{row}{an index, such as a row number} } \description{ -This function calculates a normalised mean for antimicrobial resistance between multiple observations. +Calculates a normalised mean for antimicrobial resistance between multiple observations, to help to identify similar isolates without comparing antibiograms by hand. } \details{ The mean AMR distance is a normalised numeric value to compare AMR test results and can help to identify similar isolates, without comparing antibiograms by hand. For common numeric data this distance is equal to \href{https://en.wikipedia.org/wiki/Standard_score}{Z scores} (the number of standard deviations from the mean).