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

fix documentation

This commit is contained in:
2022-10-06 11:33:30 +02:00
parent 0d8b098220
commit b9342d103e
8 changed files with 64 additions and 67 deletions

View File

@ -1174,6 +1174,7 @@ font_stripstyle <- function(x) {
progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
if (print == FALSE || n < n_min) {
# create fake/empty object
pb <- list()
pb$tick <- function() {
invisible()
@ -1183,16 +1184,17 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
}
set_clean_class(pb, new_class = "txtProgressBar")
} else if (n >= n_min) {
# rely on the progress package if it is available - it has a more verbose output
# use `progress`, which also has a timer
progress_bar <- import_fn("progress_bar", "progress", error_on_fail = FALSE)
if (!is.null(progress_bar)) {
# so we use progress::progress_bar
# a close() method was also added, see below this function
pb <- progress_bar$new(
format = "[:bar] :percent (:current/:total)",
format = "(:spin) [:bar] :percent (:current/:total,:eta)",
total = n
)
} else {
# use base R
pb <- utils::txtProgressBar(max = n, style = 3)
pb$tick <- function() {
pb$up(pb$getVal() + 1)
@ -1206,6 +1208,7 @@ progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) {
#' @export
#' @noRd
close.progress_bar <- function(con, ...) {
# for progress::progress_bar$new()
con$terminate()
}

11
R/mo.R
View File

@ -113,9 +113,8 @@
#' "staaur",
#' "S. aureus",
#' "S aureus",
#' "Staphylococcus aureus",
#' "Staphylococcus aureus (MRSA,",
#' "Zthafilokkoockus oureuz", # handles incorrect spelling
#' "Sthafilokkockus aureus", # handles incorrect spelling
#' "Staphylococcus aureus (MRSA)",
#' "MRSA", # Methicillin Resistant S. aureus
#' "VISA", # Vancomycin Intermediate S. aureus
#' "VRSA", # Vancomycin Resistant S. aureus
@ -822,6 +821,7 @@ print.mo_uncertainties <- function(x, ...) {
txt <- paste(txt,
paste0(
paste0(
"", strrep(font_grey("-"), times = options()$width), "\n",
'"', x[i, ]$original_input, '"',
" -> ",
paste0(
@ -844,7 +844,10 @@ print.mo_uncertainties <- function(x, ...) {
candidates,
sep = "\n"
)
txt <- paste0(gsub("\n\n", "\n", txt), "\n\n")
txt <- gsub("[\n]+", "\n", txt)
# remove first and last break
txt <- gsub("(^[\n]|[\n]$)", "", txt)
txt <- paste0("\n", txt, "\n")
}
cat(txt)
}

View File

@ -98,6 +98,7 @@
#' mo_authors("Klebsiella pneumoniae")
#' mo_year("Klebsiella pneumoniae")
#' mo_lpsn("Klebsiella pneumoniae")
#' mo_gbif("Klebsiella pneumoniae")
#'
#' # abbreviations known in the field -----------------------------------------
#' mo_genus("MRSA")
@ -109,20 +110,15 @@
#' mo_species("EHEC")
#'
#' # known subspecies ---------------------------------------------------------
#' mo_name("doylei")
#' mo_genus("doylei")
#' mo_species("doylei")
#' mo_subspecies("doylei")
#'
#' mo_fullname("K. pneu rh")
#' mo_shortname("K. pneu rh")
#'
#' \donttest{
#' # Becker classification, see ?as.mo ----------------------------------------
#' mo_fullname("S. epi")
#' mo_fullname("S. epi", Becker = TRUE)
#' mo_shortname("S. epi")
#' mo_shortname("S. epi", Becker = TRUE)
#' mo_fullname("Staph. epi")
#' mo_fullname("Staph. epi", Becker = TRUE)
#' mo_shortname("Staph. epi")
#' mo_shortname("Staph. epi", Becker = TRUE)
#'
#' # Lancefield classification, see ?as.mo ------------------------------------
#' mo_fullname("S. pyo")
@ -132,23 +128,19 @@
#'
#'
#' # language support --------------------------------------------------------
#' mo_gramstain("Klebsiella pneumoniae", language = "de")
#' mo_gramstain("Klebsiella pneumoniae", language = "nl")
#' mo_gramstain("Klebsiella pneumoniae", language = "es")
#' mo_gramstain("Klebsiella pneumoniae", language = "de") # German
#' mo_gramstain("Klebsiella pneumoniae", language = "nl") # Dutch
#' mo_gramstain("Klebsiella pneumoniae", language = "es") # Spanish
#' mo_gramstain("Klebsiella pneumoniae", language = "el") # Greek
#' mo_gramstain("Klebsiella pneumoniae", language = "uk") # Ukrainian
#'
#' # mo_type is equal to mo_kingdom, but mo_kingdom will remain official
#' mo_kingdom("Klebsiella pneumoniae")
#' mo_type("Klebsiella pneumoniae")
#' mo_type("Klebsiella pneumoniae")
#' mo_type("Klebsiella pneumoniae", language = "nl")
#'
#' mo_fullname("S. pyogenes",
#' Lancefield = TRUE,
#' language = "de"
#' )
#' mo_fullname("S. pyogenes",
#' Lancefield = TRUE,
#' language = "nl"
#' )
#' mo_fullname("S. pyogenes", Lancefield = TRUE, language = "de")
#' mo_fullname("S. pyogenes", Lancefield = TRUE, language = "uk")
#'
#'
#' # other --------------------------------------------------------------------
@ -158,10 +150,13 @@
#' # gram stains and intrinsic resistance can be used as a filter in dplyr verbs
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo_is_gram_positive())
#'
#' filter(mo_is_gram_positive()) %>%
#' count(mo_genus(), count = TRUE)
#' }
#' if (require("dplyr")) {
#' example_isolates %>%
#' filter(mo_is_intrinsic_resistant(ab = "vanco"))
#' filter(mo_is_intrinsic_resistant(ab = "vanco")) %>%
#' count(mo_genus(), count = TRUE)
#' }
#'
#'