1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 15:21:58 +02:00

unit test fixes

This commit is contained in:
2023-02-13 16:56:25 +01:00
parent b6d2b1398d
commit 3396236eef
5 changed files with 71 additions and 9 deletions

View File

@ -136,7 +136,7 @@
#' # run ?example_isolates for more info.
#' example_isolates
#'
#'
#' \donttest{
#' # Traditional antibiogram ----------------------------------------------
#'
#' antibiogram(example_isolates,
@ -232,6 +232,7 @@
#' if (requireNamespace("ggplot2")) {
#' ggplot2::autoplot(ab2)
#' }
#' }
antibiogram <- function(x,
antibiotics = where(is.sir),
mo_transform = "shortname",
@ -543,12 +544,14 @@ autoplot.antibiogram <- function(object, ...) {
#' @rdname antibiogram
print.antibiogram <- function(x, as_kable = !interactive(), ...) {
meet_criteria(as_kable, allow_class = "logical", has_length = 1)
if (isTRUE(as_kable) &&
# be sure not to run kable in pkgdown for our website generation
!identical(Sys.getenv("IN_PKGDOWN"), "true")) {
stop_ifnot_installed("knitr")
kable <- import_fn("kable", "knitr", error_on_fail = TRUE)
kable <- import_fn("kable", "knitr", error_on_fail = FALSE)
if (!is.null(kable) &&
isTRUE(as_kable) &&
# be sure not to run kable in pkgdown for our website generation
!identical(Sys.getenv("IN_PKGDOWN"), "true")) {
kable(x, ...)
} else {
# remove 'antibiogram' class and print with default method
class(x) <- class(x)[class(x) != "antibiogram"]