From 1c2ac70d0147c1d1218ef738e3b9d9567f73bbc8 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 16 Jan 2024 14:10:33 +0000 Subject: [PATCH 01/26] Caching progress --- R/helpers_knitr_CohortSize.R | 133 +++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 R/helpers_knitr_CohortSize.R diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R new file mode 100644 index 000000000..920fac926 --- /dev/null +++ b/R/helpers_knitr_CohortSize.R @@ -0,0 +1,133 @@ +# Integration with knitr ---- + +#' Implement S3 Method `knit_print` for all `crmPack` Classes +#' +#' @description `r lifecycle::badge("experimental")` +#' +#' We provide additional utility functions to allow human-friendly rendition of +#' crmPack objects in Markdown and Quarto files +#' +#' @return a character string that represents the object in markdown. +#' @name knit_print +NULL + +# CohortSize ---- + +# [1] "CohortSizeParts" "CohortSizeMax" "CohortSizeMin" +# [7] "CohortSizeOrdinal" + +#' Render a CohortSizeConst Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @param obj (`numeric`)\cr The CohortSizeDLT object. +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? (Not used at present) +#' @param label (`character`)\cr The word used to label the participants. See Usage Notes below. +#' @param ... (`numeric`)\cr Not used at present +#' +#' @section Usage Notes: +#' The default value of `label` is `NULL` and results in a label of `"participant"` if the cohort size is `1` and +#' `"participants"` otherwise. In other cases, the end user is responsible for ensuring consistency of number +#' between the cohort size and its label +#' @return The markdown representation of the object, as a character string +#' @seealso [`knit_print`] for more details. +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant", "participants"), ...) { + assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) + assert_flag(asis) + + paste0("A constant size of ", obj@size, " ", label) +} + +#' Render a CohortSizeRange Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @param obj (`numeric`)\cr The CohortSizeDLT object. +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? +#' @param ... (`numeric`)\cr Passed to `knitr::kable()` +#' +#' @section Usage Notes: +#' The by default, the columns are labelled `Lower`, `Upper` and `Cohort size`. The table's caption is +#' `Defined by the dose to be used in the next cohort`. These values can be overridden by passing +#' `col.names` and `caption` in the function call. +#' @return The markdown representation of the object, as a character string +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { + assert_flag(asis) + + dot_params <- list(...) + if (!("col.names" %in% names(dot.params))) { + dot_params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + } + if (!("caption" %in% names(dot.params))) { + dot_params[["caption"]] <- "Defined by the dose to be used in the next cohort" + } + rv <- object %>% + tidy() %>% + do.call(knitr::kable, dot_params) %>% + kableExtra::add_header_above(c("Dose" = 2, " " = 1)) + if (asis) { + rv <- asis_output(rv) + } + rv +} + +#' Render a CohortSizeDLT Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @param obj (`numeric`)\cr The CohortSizeDLT object. +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? +#' @param ... (`numeric`)\cr Passed to `knitr::kable`. +#' +#' @section Usage Notes: +#' The by default, the columns are labelled `Lower`, `Upper` and `Cohort size`. The table's caption is +#' `Defined by the number of DLTs so far observed`. These values can be overridden by passing +#' `col.names` and `caption` in the function call. +#' +#' @return The markdown representation of the object, as a character string +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeDLT <- function(object, asis = TRUE, ...) { + assert_flag(asis) + + dot_params <- list(...) + if (!("col.names" %in% names(dot.params))) { + dot_params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + } + if (!("caption" %in% names(dot.params))) { + dot_params[["caption"]] <- "Defined by the number of DLTs so far observed" + } + rv <- object %>% + tidy() %>% + do.call(knitr::kable, dot_params) %>% + kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) + if (asis) { + rv <- asis_output(rv) + } + rv +} + +#' Render a CohortSizeParts Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @param obj (`numeric`)\cr The CohortSizeParts object. +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? +#' @param ... (`numeric`)\cr Passed to `knitr::kable`. +#' +#' @return The markdown representation of the object, as a character string +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeParts <- function(object, asis = TRUE, ...) { + assert_flag(asis) + + rv <- paste0("A constant size of ", obj@size, " ", label) + if (asis) { + rv <- asis_output(rv) + } + rv +} From ec269fb58a18f4ced6fd917b871276a8a1c9a2c9 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Tue, 16 Jan 2024 15:27:03 +0000 Subject: [PATCH 02/26] Caching progress --- DESCRIPTION | 1 + NAMESPACE | 4 ++ R/helpers_knitr_CohortSize.R | 69 ++++++++++++++++++++-------------- man/DesignOrdinal-class.Rd | 2 +- man/RuleDesignOrdinal-class.Rd | 2 +- man/knit_print.Rd | 69 ++++++++++++++++++++++++++++++++++ 6 files changed, 116 insertions(+), 31 deletions(-) create mode 100644 man/knit_print.Rd diff --git a/DESCRIPTION b/DESCRIPTION index cf76fef82..6d541d9dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -117,6 +117,7 @@ Collate: 'Simulations-methods.R' 'crmPack-package.R' 'helpers_design.R' + 'helpers_knitr_CohortSize.R' 'helpers_model.R' 'helpers_samples.R' 'helpers_simulations.R' diff --git a/NAMESPACE b/NAMESPACE index 0b8d14d0b..66b5d7379 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -405,6 +405,10 @@ export(h_slots) export(h_test_named_numeric) export(h_validate_combine_results) export(is_logging_enabled) +export(knit_print.CohortSizeConst) +export(knit_print.CohortSizeDLT) +export(knit_print.CohortSizeParts) +export(knit_print.CohortSizeRange) export(log_trace) export(logit) export(match_within_tolerance) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 920fac926..5d2bf8fcf 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -13,21 +13,24 @@ NULL # CohortSize ---- -# [1] "CohortSizeParts" "CohortSizeMax" "CohortSizeMin" +# [1] "CohortSizeMax" "CohortSizeMin" # [7] "CohortSizeOrdinal" #' Render a CohortSizeConst Object #' #' @description `r lifecycle::badge("experimental")` -#' @param obj (`numeric`)\cr The CohortSizeDLT object. -#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? (Not used at present) +#' @param obj (`CohortSize`)\cr The object to knit_print. +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? #' @param label (`character`)\cr The word used to label the participants. See Usage Notes below. -#' @param ... (`numeric`)\cr Not used at present +#' @param ... Not used at present #' #' @section Usage Notes: -#' The default value of `label` is `NULL` and results in a label of `"participant"` if the cohort size is `1` and -#' `"participants"` otherwise. In other cases, the end user is responsible for ensuring consistency of number -#' between the cohort size and its label +#' `label` describes the trial's participants. +#' +#' It should be a character vector of length 1 or 2. If of length 2, the first +#' element describes a `cohort_size` of 1 and the second describes all other +#' `cohort_size`s. If of length 1, the character `s` is appended to the value +#' when `cohort_size` is not 1. #' @return The markdown representation of the object, as a character string #' @seealso [`knit_print`] for more details. #' @@ -37,21 +40,18 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) - paste0("A constant size of ", obj@size, " ", label) + if (length(label) == 1) { + label[2] <- paste0(label[1], "s") + } + paste0("A constant size of ", obj@size, " ", label[obj@size == 1 ? 1 : 2]) } #' Render a CohortSizeRange Object #' #' @description `r lifecycle::badge("experimental")` -#' @param obj (`numeric`)\cr The CohortSizeDLT object. -#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? -#' @param ... (`numeric`)\cr Passed to `knitr::kable()` -#' -#' @section Usage Notes: -#' The by default, the columns are labelled `Lower`, `Upper` and `Cohort size`. The table's caption is -#' `Defined by the dose to be used in the next cohort`. These values can be overridden by passing -#' `col.names` and `caption` in the function call. -#' @return The markdown representation of the object, as a character string +#' @inheritParams knit_print.CohortSizeConst +#' @inheritDotParam knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return #' #' @export #' @rdname knit_print @@ -78,8 +78,9 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { #' Render a CohortSizeDLT Object #' #' @description `r lifecycle::badge("experimental")` -#' @param obj (`numeric`)\cr The CohortSizeDLT object. -#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? +#' @inheritParams knit_print.CohortSizeConst +#' @inheritDotParam knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return #' @param ... (`numeric`)\cr Passed to `knitr::kable`. #' #' @section Usage Notes: @@ -87,8 +88,6 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { #' `Defined by the number of DLTs so far observed`. These values can be overridden by passing #' `col.names` and `caption` in the function call. #' -#' @return The markdown representation of the object, as a character string -#' #' @export #' @rdname knit_print knit_print.CohortSizeDLT <- function(object, asis = TRUE, ...) { @@ -114,18 +113,30 @@ knit_print.CohortSizeDLT <- function(object, asis = TRUE, ...) { #' Render a CohortSizeParts Object #' #' @description `r lifecycle::badge("experimental")` -#' @param obj (`numeric`)\cr The CohortSizeParts object. -#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? -#' @param ... (`numeric`)\cr Passed to `knitr::kable`. -#' -#' @return The markdown representation of the object, as a character string +#' @inheritParams knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return +#' @inheritSection knit_print.CohortSizeConst {Usage Notes} +#' @inheritDotParams knit_print.CohortSizeConst #' #' @export #' @rdname knit_print -knit_print.CohortSizeParts <- function(object, asis = TRUE, ...) { +knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, ...) { + assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) - - rv <- paste0("A constant size of ", obj@size, " ", label) + if (length(label) == 1) { + label[2] <- paste0(label[1], "s") + } + rv <- paste0( + "A size of ", + obj@cohort_sizes[1], + " ", + label[ifelse(obj@cohort_sizes[1] == 1, 1, 2)], + " in the first part and ", + obj@cohort_sizes[2], + " ", + label[ifelse(obj@cohort_sizes[2] == 1, 1, 2)], + " in the second." + ) if (asis) { rv <- asis_output(rv) } diff --git a/man/DesignOrdinal-class.Rd b/man/DesignOrdinal-class.Rd index ab513febc..ea628bcce 100644 --- a/man/DesignOrdinal-class.Rd +++ b/man/DesignOrdinal-class.Rd @@ -81,7 +81,7 @@ my_stopping <- StoppingOrdinal(1L, (my_stopping1 & my_stopping2) | my_stopping3) # Initialize the design. design <- DesignOrdinal( - model = LogisticLogNormalOrdinal( + model = LogisticLogNormalOrdinal( mean = c(-3, -4, 1), cov = diag(c(3, 4, 1)), ref_dose = 50 diff --git a/man/RuleDesignOrdinal-class.Rd b/man/RuleDesignOrdinal-class.Rd index 2c8ad09d0..dd7e92264 100644 --- a/man/RuleDesignOrdinal-class.Rd +++ b/man/RuleDesignOrdinal-class.Rd @@ -46,7 +46,7 @@ Typically, end users will not use the \code{.DefaultRuleDesignOrdinal()} functio } \examples{ RuleDesignOrdinal( - next_best =NextBestOrdinal( + next_best = NextBestOrdinal( 1L, NextBestMTD( target = 0.25, diff --git a/man/knit_print.Rd b/man/knit_print.Rd new file mode 100644 index 000000000..0d621beec --- /dev/null +++ b/man/knit_print.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/helpers_knitr_CohortSize.R +\name{knit_print} +\alias{knit_print} +\alias{knit_print.CohortSizeConst} +\alias{knit_print.CohortSizeRange} +\alias{knit_print.CohortSizeDLT} +\alias{knit_print.CohortSizeParts} +\title{Implement S3 Method \code{knit_print} for all \code{crmPack} Classes} +\usage{ +knit_print.CohortSizeConst( + obj, + asis = TRUE, + label = c("participant", "participants"), + ... +) + +knit_print.CohortSizeRange(object, asis = TRUE, ...) + +knit_print.CohortSizeDLT(object, asis = TRUE, ...) + +knit_print.CohortSizeParts(object, asis = TRUE, ...) +} +\arguments{ +\item{obj}{(\code{numeric})\cr The object to knit_print.} + +\item{asis}{(\code{flag})\cr Should the return value be wrapped in a call to \code{asis_output}?} + +\item{label}{(\code{character})\cr The word used to label the participants. See Usage Notes below.} + +\item{...}{(\code{numeric})\cr Passed to \code{knitr::kable}.} +} +\value{ +a character string that represents the object in markdown. + +The markdown representation of the object, as a character string +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +We provide additional utility functions to allow human-friendly rendition of +crmPack objects in Markdown and Quarto files + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +} +\section{Usage Notes}{ + +\code{label} describes the trial's participants. + +It should be a character vector of length 1 or 2. If of length 2, the first +element describes a \code{cohort_size} of 1 and the second describes all other +\code{cohort_size}s. If of length 1, the character \code{s} is appended to the value +when \code{cohort_size} is not 1. + + +The by default, the columns are labelled \code{Lower}, \code{Upper} and \verb{Cohort size}. The table's caption is +\verb{Defined by the number of DLTs so far observed}. These values can be overridden by passing +\code{col.names} and \code{caption} in the function call. +} + +\seealso{ +\code{\link{knit_print}} for more details. +} From cac5700281236edb86cd95fd3d7b69b45a2591bb Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Wed, 17 Jan 2024 17:16:12 +0000 Subject: [PATCH 03/26] Caching progress --- R/helpers_knitr_CohortSize.R | 137 +++++++++++++++++++++++----- tests/testthat/test-helpers_knitr.R | 79 ++++++++++++++++ 2 files changed, 194 insertions(+), 22 deletions(-) create mode 100644 tests/testthat/test-helpers_knitr.R diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 5d2bf8fcf..89326da97 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -13,9 +13,6 @@ NULL # CohortSize ---- -# [1] "CohortSizeMax" "CohortSizeMin" -# [7] "CohortSizeOrdinal" - #' Render a CohortSizeConst Object #' #' @description `r lifecycle::badge("experimental")` @@ -43,7 +40,11 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" if (length(label) == 1) { label[2] <- paste0(label[1], "s") } - paste0("A constant size of ", obj@size, " ", label[obj@size == 1 ? 1 : 2]) + rv <- paste0("A constant size of ", obj@size, " ", label[ifelse(obj@size == 1, 1, 2)]) + if (asis) { + rv <- asis_output(rv) + } + rv } #' Render a CohortSizeRange Object @@ -58,16 +59,16 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { assert_flag(asis) - dot_params <- list(...) - if (!("col.names" %in% names(dot.params))) { - dot_params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + params <- list(...) + if (!("col.names" %in% names(params))) { + params[["col.names"]] <- c("Lower", "Upper", "Cohort size") } - if (!("caption" %in% names(dot.params))) { - dot_params[["caption"]] <- "Defined by the dose to be used in the next cohort" + if (!("caption" %in% names(params))) { + params[["caption"]] <- "Defined by the dose to be used in the next cohort" } - rv <- object %>% - tidy() %>% - do.call(knitr::kable, dot_params) %>% + x <- object %>% tidy() + params[["x"]] <- x + rv <- do.call(knitr::kable, params) %>% kableExtra::add_header_above(c("Dose" = 2, " " = 1)) if (asis) { rv <- asis_output(rv) @@ -81,7 +82,7 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { #' @inheritParams knit_print.CohortSizeConst #' @inheritDotParam knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return -#' @param ... (`numeric`)\cr Passed to `knitr::kable`. +#' @param ... Passed to `knitr::kable`. #' #' @section Usage Notes: #' The by default, the columns are labelled `Lower`, `Upper` and `Cohort size`. The table's caption is @@ -90,19 +91,18 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { #' #' @export #' @rdname knit_print -knit_print.CohortSizeDLT <- function(object, asis = TRUE, ...) { +knit_print.CohortSizeDLT <- function(obj, asis = TRUE, ...) { assert_flag(asis) - dot_params <- list(...) - if (!("col.names" %in% names(dot.params))) { - dot_params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + params <- list(...) + if (!("col.names" %in% names(params))) { + params[["col.names"]] <- c("Lower", "Upper", "Cohort size") } - if (!("caption" %in% names(dot.params))) { - dot_params[["caption"]] <- "Defined by the number of DLTs so far observed" + if (!("caption" %in% names(params))) { + params[["caption"]] <- "Defined by the number of DLTs so far observed" } - rv <- object %>% - tidy() %>% - do.call(knitr::kable, dot_params) %>% + params[["x"]] <- obj %>% tidy() + rv <- do.call(knitr::kable, params) %>% kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) if (asis) { rv <- asis_output(rv) @@ -123,6 +123,7 @@ knit_print.CohortSizeDLT <- function(object, asis = TRUE, ...) { knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, ...) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) + if (length(label) == 1) { label[2] <- paste0(label[1], "s") } @@ -142,3 +143,95 @@ knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, } rv } + +#' Render a CohortSizeMax Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @inheritParams knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return +#' @params ... passed through to the `knit_print` methods of the constituent +#' rules +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeMax <- function(obj, asis = TRUE, ...) { + assert_flag(asis) + rv <- paste0( + "The maximum of the cohort sizes defined in the following rules:", + paste0( + lapply( + obj@cohort_sizes, + function(x, ...) { + knit_print(x, asis = asis, ...) + } + ), + collapse = "\n" + ), + paste = "\n" + ) + + if (asis) { + rv <- asis_output(rv) + } + rv +} + +#' Render a CohortSizeMin Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @inheritParams knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return +#' @params ... passed through to the `knit_print` methods of the constituent +#' rules +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { + assert_flag(asis) + rv <- paste0( + "The minimum of the cohort sizes defined in the following rules:", + paste0( + lapply( + obj@cohort_sizes, + function(x, ...) { + knit_print(x, asis = asis, ...) + } + ), + collapse = "\n" + ), + paste = "\n" + ) + if (asis) { + rv <- asis_output(rv) + } + rv +} + +#' Render a CohortSizeOrdinal Object +#' +#' @description `r lifecycle::badge("experimental")` +#' @inheritParams knit_print.CohortSizeConst +#' @inherit knit_print.CohortSizeConst return +#' @params ... passed through to the `knit_print` method of the standard rule +#' +#' @export +#' @rdname knit_print +knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { + asis_output( + paste0( + "Based on a toxicity garde of ", + obg@grade, + ": ", + paste0( + lapply( + obj@cohort_sizes, + function(x, ...) { + knit_print(x, asis = asis, ...) + } + ), + collapse = "\n" + ), + paste = "\n" + ) + ) +} diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R new file mode 100644 index 000000000..97ef8a018 --- /dev/null +++ b/tests/testthat/test-helpers_knitr.R @@ -0,0 +1,79 @@ +library(knitr) + +test_that("knit_print methods exist for all relevant classes", { + crmpack_class_list <- getClasses(asNamespace("crmPack")) + exclusions <- c( + "CohortSize", "CrmPackClass", "DualEndpoint", "GeneralData", "GeneralModel", + "GeneralSimulationsSummary", "Increments", "ModelEff", "ModelPseudo", + "ModelTox", "NextBest", "positive_number", "PseudoSimulations", + "PseudoDualSimulations", "PseudoDualSimulationsSummary", + "PseudoDualFlexiSimulations", "PseudoFlexiSimulations", + "PseudoSimulationsSummary", "SimulationsSummary", "Report", "SafetyWindow", + "Stopping", "Validate", + # The following classes have no constructors + "DualSimulationsSummary" + ) + crmpack_class_list <- setdiff(crmpack_class_list, exclusions) + + # See https://stackoverflow.com/questions/42738851/r-how-to-find-what-s3-method-will-be-called-on-an-object + findMethod <- function(generic, ...) { + ch <- deparse(substitute(generic)) + f <- X <- function(x, ...) UseMethod("X") + for(m in methods(ch)) assign(sub(ch, "X", m, fixed = TRUE), "body<-"(f, value = m)) + X(...) + } + + for (cls in crmpack_class_list) { + if (!isClassUnion(cls)) { + constructor_name <- paste0(".Default", cls) + if (exists(constructor_name, mode = "function")) { + tryCatch( + { + x <- do.call(paste0(".Default", cls), list()) + + result <- findMethod(knit_print, x) + # TODO Remove if (...) { warning() } else { once all methods have been implemented + if (result == "knit_print.default") { + warning(paste0("No knit_print method for ", cls, " objects")) + } else { + expect_equal(result, paste0("knit_print.", cls)) + } + }, + error = function(e) fail(paste0("Error locating knit_print method for ", cls, " objects: ", e)) + ) + } else { + warning(paste0("No default constructor for ", cls)) + } + } + } +}) + +# CohortSize --- + +# CohortSizeConst + +test_that("knit_print.CohortSizeConst works correctly", { + x <- CohortSizeConst(3) + rv <- knit_print(x) + expect_equal(rv, "A constant size of 3 participants", ignore_attr = TRUE) + expect_class(rv, "knit_asis") + + x <- CohortSizeConst(2) + rv <- knit_print(x, label = "subject") + expect_equal(rv, "A constant size of 2 subjects", ignore_attr = TRUE) + + x <- CohortSizeConst(1) + rv <- knit_print(x, label = "subject") + expect_equal(rv, "A constant size of 1 subject", ignore_attr = TRUE) + + x <- CohortSizeConst(3) + rv <- knit_print(x, asis = FALSE) + expect_equal(rv, "A constant size of 3 participants") + expect_class(rv, "character") +}) + +# CohortSizeRange + +test_that("knit_print.CohortSizeConst works correctly", { +}) + From 419cd4622131e7b76f889fd0604122abcb1083de Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Wed, 31 Jan 2024 18:04:51 +0000 Subject: [PATCH 04/26] knit_print methods for sub-classes of CohortSize --- DESCRIPTION | 2 +- NAMESPACE | 12 +- R/helpers_knitr_CohortSize.R | 67 +- man/knit_print.Rd | 51 +- .../knit_print_CohortSizeConst.html | 3258 ++++++++++++++++ .../knit_print_CohortSizeDLT.html | 3290 ++++++++++++++++ .../knit_print_CohortSizeMax.html | 3363 +++++++++++++++++ .../knit_print_CohortSizeMin.html | 3363 +++++++++++++++++ .../knit_print_CohortSizeOrdinal.html | 3311 ++++++++++++++++ .../knit_print_CohortSizeParts.html | 3258 ++++++++++++++++ .../knit_print_CohortSizeRange.html | 3290 ++++++++++++++++ .../testthat/fixtures/knit_print_template.qmd | 20 + tests/testthat/test-helpers_knitr.R | 58 +- 13 files changed, 23266 insertions(+), 77 deletions(-) create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html create mode 100644 tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html create mode 100644 tests/testthat/fixtures/knit_print_template.qmd diff --git a/DESCRIPTION b/DESCRIPTION index 6d541d9dc..b5f84bd15 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -46,6 +46,7 @@ Imports: GenSA, gridExtra, kableExtra, + knitr, lifecycle, magrittr, methods, @@ -64,7 +65,6 @@ Suggests: covr, data.tree, ggmcmc, - knitr, rmarkdown, stringr, testthat (>= 3.0.0), diff --git a/NAMESPACE b/NAMESPACE index 66b5d7379..71ea4437d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,12 @@ # Generated by roxygen2: do not edit by hand +S3method(knit_print,CohortSizeConst) +S3method(knit_print,CohortSizeDLT) +S3method(knit_print,CohortSizeMax) +S3method(knit_print,CohortSizeMin) +S3method(knit_print,CohortSizeOrdinal) +S3method(knit_print,CohortSizeParts) +S3method(knit_print,CohortSizeRange) S3method(plot,gtable) S3method(print,gtable) export("%>%") @@ -405,10 +412,6 @@ export(h_slots) export(h_test_named_numeric) export(h_validate_combine_results) export(is_logging_enabled) -export(knit_print.CohortSizeConst) -export(knit_print.CohortSizeDLT) -export(knit_print.CohortSizeParts) -export(knit_print.CohortSizeRange) export(log_trace) export(logit) export(match_within_tolerance) @@ -613,6 +616,7 @@ importFrom(kableExtra,column_spec) importFrom(kableExtra,kable) importFrom(kableExtra,kable_styling) importFrom(kableExtra,kbl) +importFrom(knitr,knit_print) importFrom(lifecycle,badge) importFrom(magrittr,"%>%") importFrom(mvtnorm,rmvnorm) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 89326da97..f78341c2e 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -1,6 +1,8 @@ -# Integration with knitr ---- +#' @importFrom knitr knit_print +NULL -#' Implement S3 Method `knit_print` for all `crmPack` Classes +# Integration with knitr ---- +#' #' #' @description `r lifecycle::badge("experimental")` #' @@ -46,12 +48,13 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" } rv } +registerS3method("knit_print", "CohortSizeConst", knit_print.CohortSizeConst) #' Render a CohortSizeRange Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst -#' @inheritDotParam knit_print.CohortSizeConst +#' @inheritDotParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' #' @export @@ -59,28 +62,29 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { assert_flag(asis) - params <- list(...) - if (!("col.names" %in% names(params))) { - params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + param <- list(...) + if (!("col.names" %in% names(param))) { + param[["col.names"]] <- c("Lower", "Upper", "Cohort size") } - if (!("caption" %in% names(params))) { - params[["caption"]] <- "Defined by the dose to be used in the next cohort" + if (!("caption" %in% names(param))) { + param[["caption"]] <- "Defined by the dose to be used in the next cohort" } x <- object %>% tidy() - params[["x"]] <- x - rv <- do.call(knitr::kable, params) %>% + param[["x"]] <- x + rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("Dose" = 2, " " = 1)) if (asis) { rv <- asis_output(rv) } rv } +registerS3method("knit_print", "CohortSizeRange", knit_print.CohortSizeRange) #' Render a CohortSizeDLT Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst -#' @inheritDotParam knit_print.CohortSizeConst +#' @inheritDotParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @param ... Passed to `knitr::kable`. #' @@ -94,28 +98,29 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { knit_print.CohortSizeDLT <- function(obj, asis = TRUE, ...) { assert_flag(asis) - params <- list(...) - if (!("col.names" %in% names(params))) { - params[["col.names"]] <- c("Lower", "Upper", "Cohort size") + param <- list(...) + if (!("col.names" %in% names(param))) { + param[["col.names"]] <- c("Lower", "Upper", "Cohort size") } - if (!("caption" %in% names(params))) { - params[["caption"]] <- "Defined by the number of DLTs so far observed" + if (!("caption" %in% names(param))) { + param[["caption"]] <- "Defined by the number of DLTs so far observed" } - params[["x"]] <- obj %>% tidy() - rv <- do.call(knitr::kable, params) %>% + param[["x"]] <- obj %>% tidy() + rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) if (asis) { rv <- asis_output(rv) } rv } +registerS3method("knit_print", "CohortSizeDLT", knit_print.CohortSizeDLT) #' Render a CohortSizeParts Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return -#' @inheritSection knit_print.CohortSizeConst {Usage Notes} +#' @inheritSection knit_print.CohortSizeConst Usage Notes #' @inheritDotParams knit_print.CohortSizeConst #' #' @export @@ -143,13 +148,14 @@ knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, } rv } +registerS3method("knit_print", "CohortSizeParts", knit_print.CohortSizeParts) #' Render a CohortSizeMax Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return -#' @params ... passed through to the `knit_print` methods of the constituent +#' @param ... passed through to the `knit_print` methods of the constituent #' rules #' #' @export @@ -175,13 +181,14 @@ knit_print.CohortSizeMax <- function(obj, asis = TRUE, ...) { } rv } +registerS3method("knit_print", "CohortSizeMax", knit_print.CohortSizeMax) #' Render a CohortSizeMin Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return -#' @params ... passed through to the `knit_print` methods of the constituent +#' @param ... passed through to the `knit_print` methods of the constituent #' rules #' #' @export @@ -206,32 +213,26 @@ knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { } rv } +registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' Render a CohortSizeOrdinal Object #' #' @description `r lifecycle::badge("experimental")` #' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return -#' @params ... passed through to the `knit_print` method of the standard rule +#' @param ... passed through to the `knit_print` method of the standard rule #' #' @export #' @rdname knit_print -knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeOrdinal <- function(obj, asis = TRUE, ...) { asis_output( paste0( "Based on a toxicity garde of ", - obg@grade, + obj@grade, ": ", - paste0( - lapply( - obj@cohort_sizes, - function(x, ...) { - knit_print(x, asis = asis, ...) - } - ), - collapse = "\n" - ), + paste0(knit_print(obj@rule,asis = asis, ...), collapse = "\n"), paste = "\n" ) ) } +registerS3method("knit_print", "CohortSizeOrdinal", knit_print.CohortSizeOrdinal) diff --git a/man/knit_print.Rd b/man/knit_print.Rd index 0d621beec..3fb0e4c41 100644 --- a/man/knit_print.Rd +++ b/man/knit_print.Rd @@ -6,29 +6,37 @@ \alias{knit_print.CohortSizeRange} \alias{knit_print.CohortSizeDLT} \alias{knit_print.CohortSizeParts} -\title{Implement S3 Method \code{knit_print} for all \code{crmPack} Classes} +\alias{knit_print.CohortSizeMax} +\alias{knit_print.CohortSizeMin} +\alias{knit_print.CohortSizeOrdinal} +\title{Render a CohortSizeConst Object} \usage{ -knit_print.CohortSizeConst( - obj, - asis = TRUE, - label = c("participant", "participants"), - ... -) +\method{knit_print}{CohortSizeConst}(obj, asis = TRUE, label = c("participant", "participants"), ...) -knit_print.CohortSizeRange(object, asis = TRUE, ...) +\method{knit_print}{CohortSizeRange}(object, asis = TRUE, ...) -knit_print.CohortSizeDLT(object, asis = TRUE, ...) +\method{knit_print}{CohortSizeDLT}(obj, asis = TRUE, ...) -knit_print.CohortSizeParts(object, asis = TRUE, ...) +\method{knit_print}{CohortSizeParts}(obj, label = "participant", asis = TRUE, ...) + +\method{knit_print}{CohortSizeMax}(obj, asis = TRUE, ...) + +\method{knit_print}{CohortSizeMin}(obj, asis = TRUE, ...) + +\method{knit_print}{CohortSizeOrdinal}(obj, asis = TRUE, ...) } \arguments{ -\item{obj}{(\code{numeric})\cr The object to knit_print.} +\item{obj}{(\code{CohortSize})\cr The object to knit_print.} \item{asis}{(\code{flag})\cr Should the return value be wrapped in a call to \code{asis_output}?} \item{label}{(\code{character})\cr The word used to label the participants. See Usage Notes below.} -\item{...}{(\code{numeric})\cr Passed to \code{knitr::kable}.} +\item{...}{ + Arguments passed on to \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}}, \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}}, \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}} + \describe{ + \item{\code{}}{} + }} } \value{ a character string that represents the object in markdown. @@ -47,6 +55,12 @@ crmPack objects in Markdown and Quarto files \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} } \section{Usage Notes}{ @@ -59,6 +73,19 @@ element describes a \code{cohort_size} of 1 and the second describes all other when \code{cohort_size} is not 1. +The by default, the columns are labelled \code{Lower}, \code{Upper} and \verb{Cohort size}. The table's caption is +\verb{Defined by the number of DLTs so far observed}. These values can be overridden by passing +\code{col.names} and \code{caption} in the function call. + + +\code{label} describes the trial's participants. + +It should be a character vector of length 1 or 2. If of length 2, the first +element describes a \code{cohort_size} of 1 and the second describes all other +\code{cohort_size}s. If of length 1, the character \code{s} is appended to the value +when \code{cohort_size} is not 1. + + The by default, the columns are labelled \code{Lower}, \code{Upper} and \verb{Cohort size}. The table's caption is \verb{Defined by the number of DLTs so far observed}. These values can be overridden by passing \code{col.names} and \code{caption} in the function call. diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html new file mode 100644 index 000000000..f38078742 --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html @@ -0,0 +1,3258 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeConst"
+
+
+

A constant size of 3 participants

+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html new file mode 100644 index 000000000..0a27e4492 --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html @@ -0,0 +1,3290 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeDLT"
+
+
+ + +++++ + + + + + + + + + + + + + + + + + + + + + + + +
Defined by the number of DLTs so far observed
+No of DLTs +
LowerUpperCohort size
011
1Inf3
+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html new file mode 100644 index 000000000..30a9cb0ce --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html @@ -0,0 +1,3363 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeMax"
+
+
+The maximum of the cohort sizes defined in the following rules: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +10 + +1 +
+10 + +Inf + +3 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the number of DLTs so far observed +
+
+No of DLTs +
+
+
+Lower + +Upper + +Cohort size +
+0 + +1 + +1 +
+1 + +Inf + +3 +
+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html new file mode 100644 index 000000000..4d40b7d3e --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html @@ -0,0 +1,3363 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeMin"
+
+
+The minimum of the cohort sizes defined in the following rules: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +10 + +1 +
+10 + +Inf + +3 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the number of DLTs so far observed +
+
+No of DLTs +
+
+
+Lower + +Upper + +Cohort size +
+0 + +1 + +1 +
+1 + +Inf + +3 +
+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html new file mode 100644 index 000000000..04ef15ade --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html @@ -0,0 +1,3311 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeOrdinal"
+
+
+Based on a toxicity garde of 1: + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +30 + +1 +
+30 + +Inf + +3 +
+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html new file mode 100644 index 000000000..7c4eceb16 --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html @@ -0,0 +1,3258 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeParts"
+
+
+

A size of 1 participant in the first part and 3 participants in the second.

+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html new file mode 100644 index 000000000..0bba5c584 --- /dev/null +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html @@ -0,0 +1,3290 @@ + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+
+

Test

+
+ + + +
+ + + + +
+ + +
+ +
+
+
ℹ Loading crmPack
+
+
+
[1] "CohortSizeRange"
+
+
+ + +++++ + + + + + + + + + + + + + + + + + + + + + + + +
Defined by the dose to be used in the next cohort
+Dose +
LowerUpperCohort size
0301
30Inf3
+
+
+ +
+ + +
+ + + + \ No newline at end of file diff --git a/tests/testthat/fixtures/knit_print_template.qmd b/tests/testthat/fixtures/knit_print_template.qmd new file mode 100644 index 000000000..f103f1647 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_template.qmd @@ -0,0 +1,20 @@ +--- +title: "Test" +format: html +editor: visual +embed-resources: true +params: + class_name: "CohortSizeConst" +--- + +```{r} +#| echo: FALSE + +suppressPackageStartupMessages ({ + devtools::load_all() + library(knitr) +}) + +print(params$class_name) +do.call(paste0(".Default", params$class_name), list()) +``` diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 97ef8a018..4a252d681 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -1,6 +1,7 @@ library(knitr) +devtools::load_all() -test_that("knit_print methods exist for all relevant classes", { +test_that("knit_print methods exist for all relevant classes and produce consistent output", { crmpack_class_list <- getClasses(asNamespace("crmPack")) exclusions <- c( "CohortSize", "CrmPackClass", "DualEndpoint", "GeneralData", "GeneralModel", @@ -16,36 +17,43 @@ test_that("knit_print methods exist for all relevant classes", { crmpack_class_list <- setdiff(crmpack_class_list, exclusions) # See https://stackoverflow.com/questions/42738851/r-how-to-find-what-s3-method-will-be-called-on-an-object - findMethod <- function(generic, ...) { + identifyMethod <- function(generic, ...) { ch <- deparse(substitute(generic)) f <- X <- function(x, ...) UseMethod("X") for(m in methods(ch)) assign(sub(ch, "X", m, fixed = TRUE), "body<-"(f, value = m)) X(...) } - for (cls in crmpack_class_list) { - if (!isClassUnion(cls)) { - constructor_name <- paste0(".Default", cls) - if (exists(constructor_name, mode = "function")) { - tryCatch( - { - x <- do.call(paste0(".Default", cls), list()) - - result <- findMethod(knit_print, x) - # TODO Remove if (...) { warning() } else { once all methods have been implemented - if (result == "knit_print.default") { - warning(paste0("No knit_print method for ", cls, " objects")) - } else { - expect_equal(result, paste0("knit_print.", cls)) - } - }, - error = function(e) fail(paste0("Error locating knit_print method for ", cls, " objects: ", e)) - ) - } else { - warning(paste0("No default constructor for ", cls)) + # For each relevant class... + withr::with_dir( + # Quarto can't specify location of output file + # See https://github.com/quarto-dev/quarto-r/issues/81 + test_path("fixtures"), { + for (cls in crmpack_class_list) { + if (!isClassUnion(cls)) { + methodName <- identifyMethod( + knit_print, + do.call(paste0(".Default", cls), list()) + ) + if (methodName != "knit_print.default") { + outFileName <- paste0("knit_print_", cls, ".html") + withr::with_file( + outFileName, { + quarto::quarto_render( + input = test_path("knit_print_template.qmd"), + execute_params = list("class_name" = cls), + output_file = outFileName + ) + expect_snapshot_file(outFileName) + } + ) + } + } else { + warning(paste0("No default constructor for ", cls)) + } } } - } + ) }) # CohortSize --- @@ -72,8 +80,4 @@ test_that("knit_print.CohortSizeConst works correctly", { expect_class(rv, "character") }) -# CohortSizeRange - -test_that("knit_print.CohortSizeConst works correctly", { -}) From a949cd27db4bef9e05a7f48872d64cd8344a1df8 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 07:53:59 +0000 Subject: [PATCH 05/26] Add comments --- tests/testthat/test-helpers_knitr.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 4a252d681..1fb9978b6 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -24,17 +24,20 @@ test_that("knit_print methods exist for all relevant classes and produce consist X(...) } - # For each relevant class... + # Temporarily change the working directory because Quarto can't specify + # location of output file + # See https://github.com/quarto-dev/quarto-r/issues/81 withr::with_dir( - # Quarto can't specify location of output file - # See https://github.com/quarto-dev/quarto-r/issues/81 test_path("fixtures"), { + # For each relevant class... for (cls in crmpack_class_list) { if (!isClassUnion(cls)) { + # Obtain the corresponding knit_print method... methodName <- identifyMethod( knit_print, do.call(paste0(".Default", cls), list()) ) + # ... and if the default has been overridden, test it if (methodName != "knit_print.default") { outFileName <- paste0("knit_print_", cls, ".html") withr::with_file( From 8a789f2abde075f880c5f5205825c714fbd0239f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:57:19 +0000 Subject: [PATCH 06/26] [skip actions] Restyle files --- R/helpers_knitr_CohortSize.R | 2 +- tests/testthat/fixtures/knit_print_template.qmd | 2 +- tests/testthat/test-helpers_knitr.R | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index f78341c2e..a997f0816 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -230,7 +230,7 @@ knit_print.CohortSizeOrdinal <- function(obj, asis = TRUE, ...) { "Based on a toxicity garde of ", obj@grade, ": ", - paste0(knit_print(obj@rule,asis = asis, ...), collapse = "\n"), + paste0(knit_print(obj@rule, asis = asis, ...), collapse = "\n"), paste = "\n" ) ) diff --git a/tests/testthat/fixtures/knit_print_template.qmd b/tests/testthat/fixtures/knit_print_template.qmd index f103f1647..044e8c419 100644 --- a/tests/testthat/fixtures/knit_print_template.qmd +++ b/tests/testthat/fixtures/knit_print_template.qmd @@ -10,7 +10,7 @@ params: ```{r} #| echo: FALSE -suppressPackageStartupMessages ({ +suppressPackageStartupMessages({ devtools::load_all() library(knitr) }) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 1fb9978b6..c8ed05b60 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -20,7 +20,7 @@ test_that("knit_print methods exist for all relevant classes and produce consist identifyMethod <- function(generic, ...) { ch <- deparse(substitute(generic)) f <- X <- function(x, ...) UseMethod("X") - for(m in methods(ch)) assign(sub(ch, "X", m, fixed = TRUE), "body<-"(f, value = m)) + for (m in methods(ch)) assign(sub(ch, "X", m, fixed = TRUE), "body<-"(f, value = m)) X(...) } @@ -28,7 +28,8 @@ test_that("knit_print methods exist for all relevant classes and produce consist # location of output file # See https://github.com/quarto-dev/quarto-r/issues/81 withr::with_dir( - test_path("fixtures"), { + test_path("fixtures"), + { # For each relevant class... for (cls in crmpack_class_list) { if (!isClassUnion(cls)) { @@ -41,7 +42,8 @@ test_that("knit_print methods exist for all relevant classes and produce consist if (methodName != "knit_print.default") { outFileName <- paste0("knit_print_", cls, ".html") withr::with_file( - outFileName, { + outFileName, + { quarto::quarto_render( input = test_path("knit_print_template.qmd"), execute_params = list("class_name" = cls), @@ -65,16 +67,16 @@ test_that("knit_print methods exist for all relevant classes and produce consist test_that("knit_print.CohortSizeConst works correctly", { x <- CohortSizeConst(3) - rv <- knit_print(x) + rv <- knit_print(x) expect_equal(rv, "A constant size of 3 participants", ignore_attr = TRUE) expect_class(rv, "knit_asis") x <- CohortSizeConst(2) - rv <- knit_print(x, label = "subject") + rv <- knit_print(x, label = "subject") expect_equal(rv, "A constant size of 2 subjects", ignore_attr = TRUE) x <- CohortSizeConst(1) - rv <- knit_print(x, label = "subject") + rv <- knit_print(x, label = "subject") expect_equal(rv, "A constant size of 1 subject", ignore_attr = TRUE) x <- CohortSizeConst(3) @@ -82,5 +84,3 @@ test_that("knit_print.CohortSizeConst works correctly", { expect_equal(rv, "A constant size of 3 participants") expect_class(rv, "character") }) - - From aec7c86701967851f950bec3dec4b8391b5d6390 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 08:03:42 +0000 Subject: [PATCH 07/26] Additional comments, fixing one R CMD CHECK warning elsewhere --- R/Design-methods.R | 2 +- tests/testthat/test-helpers_knitr.R | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/R/Design-methods.R b/R/Design-methods.R index 4d876c249..2dc678ad6 100644 --- a/R/Design-methods.R +++ b/R/Design-methods.R @@ -140,7 +140,7 @@ setMethod("simulate", prob = thisProb, prob_placebo = thisProb.PL, cohort_size = thisSize, - cohort_size_pl = thisSize.PL, + cohort_size_placebo = thisSize.PL, dose_grid = object@data@doseGrid[1], first_separate = firstSeparate ) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 1fb9978b6..0d828c077 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -40,6 +40,9 @@ test_that("knit_print methods exist for all relevant classes and produce consist # ... and if the default has been overridden, test it if (methodName != "knit_print.default") { outFileName <- paste0("knit_print_", cls, ".html") + # with_file guarantees that the test file will be deleted automatically + # once the snapshot has been compared with the previous version, which + # can be found in /_snaps/helpers_knitr withr::with_file( outFileName, { quarto::quarto_render( From 467c6984aca138dde9898d31a120c11152cf2c0f Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 08:09:47 +0000 Subject: [PATCH 08/26] Fix pkgdown error --- _pkgdown.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/_pkgdown.yaml b/_pkgdown.yaml index 91126ac39..97a252b7e 100644 --- a/_pkgdown.yaml +++ b/_pkgdown.yaml @@ -394,6 +394,7 @@ reference: - is_logging_enabled - log_trace - dapply + - knit_print - title: Classes contents: - CohortSizeOrdinal-class From 308430ef23e8e0a40f7ba82e32208aee3831bbe0 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 08:30:34 +0000 Subject: [PATCH 09/26] Fix R CMD CHECK warning --- R/helpers_knitr_CohortSize.R | 24 ++++++++++++------------ tests/testthat/test-helpers_knitr.R | 1 - 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index a997f0816..e70d7f60b 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -19,7 +19,7 @@ NULL #' #' @description `r lifecycle::badge("experimental")` #' @param obj (`CohortSize`)\cr The object to knit_print. -#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `asis_output`? +#' @param asis (`flag`)\cr Should the return value be wrapped in a call to `knitr::asis_output`? #' @param label (`character`)\cr The word used to label the participants. See Usage Notes below. #' @param ... Not used at present #' @@ -35,7 +35,7 @@ NULL #' #' @export #' @rdname knit_print -knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant", "participants"), ...) { +knit_print.CohortSizeConst <- function(obj, asis = TRUE, ..., label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) @@ -44,7 +44,7 @@ knit_print.CohortSizeConst <- function(obj, asis = TRUE, label = c("participant" } rv <- paste0("A constant size of ", obj@size, " ", label[ifelse(obj@size == 1, 1, 2)]) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -59,7 +59,7 @@ registerS3method("knit_print", "CohortSizeConst", knit_print.CohortSizeConst) #' #' @export #' @rdname knit_print -knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { +knit_print.CohortSizeRange <- function(obj, asis = TRUE, ...) { assert_flag(asis) param <- list(...) @@ -69,12 +69,12 @@ knit_print.CohortSizeRange <- function(object, asis = TRUE, ...) { if (!("caption" %in% names(param))) { param[["caption"]] <- "Defined by the dose to be used in the next cohort" } - x <- object %>% tidy() + x <- obj %>% tidy() param[["x"]] <- x rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("Dose" = 2, " " = 1)) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -109,7 +109,7 @@ knit_print.CohortSizeDLT <- function(obj, asis = TRUE, ...) { rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -125,7 +125,7 @@ registerS3method("knit_print", "CohortSizeDLT", knit_print.CohortSizeDLT) #' #' @export #' @rdname knit_print -knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, ...) { +knit_print.CohortSizeParts <- function(obj, asis = TRUE, ..., label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) @@ -144,7 +144,7 @@ knit_print.CohortSizeParts <- function(obj, label = "participant", asis = TRUE, " in the second." ) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -177,7 +177,7 @@ knit_print.CohortSizeMax <- function(obj, asis = TRUE, ...) { ) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -209,7 +209,7 @@ knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { paste = "\n" ) if (asis) { - rv <- asis_output(rv) + rv <- knitr::asis_output(rv) } rv } @@ -225,7 +225,7 @@ registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' @export #' @rdname knit_print knit_print.CohortSizeOrdinal <- function(obj, asis = TRUE, ...) { - asis_output( + knitr::asis_output( paste0( "Based on a toxicity garde of ", obj@grade, diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 0a73e03cc..6e73adf6c 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -1,5 +1,4 @@ library(knitr) -devtools::load_all() test_that("knit_print methods exist for all relevant classes and produce consistent output", { crmpack_class_list <- getClasses(asNamespace("crmPack")) From 2a99fc98c466a8f5ef25640ca88a3b4a7d9e7596 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 10:24:19 +0000 Subject: [PATCH 10/26] Update documentation --- R/helpers_knitr_CohortSize.R | 23 +++++++---------------- man/knit_print.Rd | 24 ++++++++++-------------- tests/testthat/test-helpers_knitr.R | 3 +++ 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index e70d7f60b..f8b261dfa 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -35,7 +35,7 @@ NULL #' #' @export #' @rdname knit_print -knit_print.CohortSizeConst <- function(obj, asis = TRUE, ..., label = c("participant", "participants")) { +knit_print.CohortSizeConst <- function(obj, ..., asis = TRUE, label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) @@ -53,13 +53,11 @@ registerS3method("knit_print", "CohortSizeConst", knit_print.CohortSizeConst) #' Render a CohortSizeRange Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst -#' @inheritDotParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' #' @export #' @rdname knit_print -knit_print.CohortSizeRange <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeRange <- function(obj, ..., asis = TRUE) { assert_flag(asis) param <- list(...) @@ -83,8 +81,6 @@ registerS3method("knit_print", "CohortSizeRange", knit_print.CohortSizeRange) #' Render a CohortSizeDLT Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst -#' @inheritDotParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @param ... Passed to `knitr::kable`. #' @@ -95,7 +91,7 @@ registerS3method("knit_print", "CohortSizeRange", knit_print.CohortSizeRange) #' #' @export #' @rdname knit_print -knit_print.CohortSizeDLT <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeDLT <- function(obj, ..., asis = TRUE) { assert_flag(asis) param <- list(...) @@ -118,14 +114,12 @@ registerS3method("knit_print", "CohortSizeDLT", knit_print.CohortSizeDLT) #' Render a CohortSizeParts Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @inheritSection knit_print.CohortSizeConst Usage Notes -#' @inheritDotParams knit_print.CohortSizeConst #' #' @export #' @rdname knit_print -knit_print.CohortSizeParts <- function(obj, asis = TRUE, ..., label = c("participant", "participants")) { +knit_print.CohortSizeParts <- function(obj, ..., asis = TRUE, label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) @@ -153,14 +147,13 @@ registerS3method("knit_print", "CohortSizeParts", knit_print.CohortSizeParts) #' Render a CohortSizeMax Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @param ... passed through to the `knit_print` methods of the constituent #' rules #' #' @export #' @rdname knit_print -knit_print.CohortSizeMax <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeMax <- function(obj, ..., asis = TRUE) { assert_flag(asis) rv <- paste0( "The maximum of the cohort sizes defined in the following rules:", @@ -186,14 +179,13 @@ registerS3method("knit_print", "CohortSizeMax", knit_print.CohortSizeMax) #' Render a CohortSizeMin Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @param ... passed through to the `knit_print` methods of the constituent #' rules #' #' @export #' @rdname knit_print -knit_print.CohortSizeMin <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeMin <- function(obj, ..., asis = TRUE) { assert_flag(asis) rv <- paste0( "The minimum of the cohort sizes defined in the following rules:", @@ -218,13 +210,12 @@ registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' Render a CohortSizeOrdinal Object #' #' @description `r lifecycle::badge("experimental")` -#' @inheritParams knit_print.CohortSizeConst #' @inherit knit_print.CohortSizeConst return #' @param ... passed through to the `knit_print` method of the standard rule #' #' @export #' @rdname knit_print -knit_print.CohortSizeOrdinal <- function(obj, asis = TRUE, ...) { +knit_print.CohortSizeOrdinal <- function(obj, ..., asis = TRUE) { knitr::asis_output( paste0( "Based on a toxicity garde of ", diff --git a/man/knit_print.Rd b/man/knit_print.Rd index 3fb0e4c41..21da22511 100644 --- a/man/knit_print.Rd +++ b/man/knit_print.Rd @@ -11,32 +11,28 @@ \alias{knit_print.CohortSizeOrdinal} \title{Render a CohortSizeConst Object} \usage{ -\method{knit_print}{CohortSizeConst}(obj, asis = TRUE, label = c("participant", "participants"), ...) +\method{knit_print}{CohortSizeConst}(obj, ..., asis = TRUE, label = c("participant", "participants")) -\method{knit_print}{CohortSizeRange}(object, asis = TRUE, ...) +\method{knit_print}{CohortSizeRange}(obj, ..., asis = TRUE) -\method{knit_print}{CohortSizeDLT}(obj, asis = TRUE, ...) +\method{knit_print}{CohortSizeDLT}(obj, ..., asis = TRUE) -\method{knit_print}{CohortSizeParts}(obj, label = "participant", asis = TRUE, ...) +\method{knit_print}{CohortSizeParts}(obj, ..., asis = TRUE, label = c("participant", "participants")) -\method{knit_print}{CohortSizeMax}(obj, asis = TRUE, ...) +\method{knit_print}{CohortSizeMax}(obj, ..., asis = TRUE) -\method{knit_print}{CohortSizeMin}(obj, asis = TRUE, ...) +\method{knit_print}{CohortSizeMin}(obj, ..., asis = TRUE) -\method{knit_print}{CohortSizeOrdinal}(obj, asis = TRUE, ...) +\method{knit_print}{CohortSizeOrdinal}(obj, ..., asis = TRUE) } \arguments{ \item{obj}{(\code{CohortSize})\cr The object to knit_print.} -\item{asis}{(\code{flag})\cr Should the return value be wrapped in a call to \code{asis_output}?} +\item{...}{passed through to the \code{knit_print} method of the standard rule} -\item{label}{(\code{character})\cr The word used to label the participants. See Usage Notes below.} +\item{asis}{(\code{flag})\cr Should the return value be wrapped in a call to \code{knitr::asis_output}?} -\item{...}{ - Arguments passed on to \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}}, \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}}, \code{\link[=knit_print.CohortSizeConst]{knit_print.CohortSizeConst}} - \describe{ - \item{\code{}}{} - }} +\item{label}{(\code{character})\cr The word used to label the participants. See Usage Notes below.} } \value{ a character string that represents the object in markdown. diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 6e73adf6c..d5e50cbdb 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -1,4 +1,7 @@ library(knitr) +if (!testthat::is_checking()) { + devtools::load_all() +} test_that("knit_print methods exist for all relevant classes and produce consistent output", { crmpack_class_list <- getClasses(asNamespace("crmPack")) From 672e1f27ab574642438c5339b712a0674d3e768b Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 15:03:52 +0000 Subject: [PATCH 11/26] Switch from Quarto to Rmd --- R/helpers_knitr_CohortSize.R | 4 +- .../knit_print_CohortSizeConst.html | 3512 ++-------------- .../knit_print_CohortSizeDLT.html | 3588 ++--------------- .../knit_print_CohortSizeMax.html | 3527 ++-------------- .../knit_print_CohortSizeMin.html | 3527 ++-------------- .../knit_print_CohortSizeOrdinal.html | 3526 ++-------------- .../knit_print_CohortSizeParts.html | 3513 ++-------------- .../knit_print_CohortSizeRange.html | 3588 ++--------------- .../fixtures/knit_print_CohortSizeConst.html | 406 ++ .../fixtures/knit_print_CohortSizeDLT.html | 456 +++ .../fixtures/knit_print_CohortSizeMax.html | 508 +++ .../fixtures/knit_print_CohortSizeMin.html | 508 +++ .../knit_print_CohortSizeOrdinal.html | 457 +++ .../fixtures/knit_print_CohortSizeParts.html | 407 ++ .../fixtures/knit_print_CohortSizeRange.html | 456 +++ ...t_template.qmd => knit_print_template.Rmd} | 8 +- tests/testthat/test-helpers_knitr.R | 25 +- 17 files changed, 5638 insertions(+), 22378 deletions(-) create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeConst.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeDLT.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeMax.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeMin.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeParts.html create mode 100644 tests/testthat/fixtures/knit_print_CohortSizeRange.html rename tests/testthat/fixtures/{knit_print_template.qmd => knit_print_template.Rmd} (75%) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index f8b261dfa..53d2ca535 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -42,7 +42,7 @@ knit_print.CohortSizeConst <- function(obj, ..., asis = TRUE, label = c("partici if (length(label) == 1) { label[2] <- paste0(label[1], "s") } - rv <- paste0("A constant size of ", obj@size, " ", label[ifelse(obj@size == 1, 1, 2)]) + rv <- paste0("A constant size of ", obj@size, " ", label[ifelse(obj@size == 1, 1, 2)], ".") if (asis) { rv <- knitr::asis_output(rv) } @@ -218,7 +218,7 @@ registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) knit_print.CohortSizeOrdinal <- function(obj, ..., asis = TRUE) { knitr::asis_output( paste0( - "Based on a toxicity garde of ", + "Based on a toxicity grade of ", obj@grade, ": ", paste0(knit_print(obj@rule, asis = asis, ...), collapse = "\n"), diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html index f38078742..7f5ae1ce7 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html @@ -1,3258 +1,406 @@ - - - + - + + + + -Test - - - + + + + + + + + + + - // read a meta tag value - function getMeta(metaName) { - const metas = window.document.getElementsByTagName("meta"); - for (let i = 0; i < metas.length; i++) { - if (metas[i].getAttribute("name") === metaName) { - return metas[i].getAttribute("content"); - } - } - return ""; - } + - async function findAndActivateCategories() { - const currentPagePath = offsetAbsoluteUrl(window.location.href); - const response = await fetch(offsetRelativeUrl("listings.json")); - if (response.status == 200) { - return response.json().then(function (listingPaths) { - const listingHrefs = []; - for (const listingPath of listingPaths) { - const pathWithoutLeadingSlash = listingPath.listing.substring(1); - for (const item of listingPath.items) { - if ( - item === currentPagePath || - item === currentPagePath + "index.html" - ) { - // Resolve this path against the offset to be sure - // we already are using the correct path to the listing - // (this adjusts the listing urls to be rooted against - // whatever root the page is actually running against) - const relative = offsetRelativeUrl(pathWithoutLeadingSlash); - const baseUrl = window.location; - const resolvedPath = new URL(relative, baseUrl); - listingHrefs.push(resolvedPath.pathname); - break; - } - } - } - - // Look up the tree for a nearby linting and use that if we find one - const nearestListing = findNearestParentListing( - offsetAbsoluteUrl(window.location.pathname), - listingHrefs - ); - if (nearestListing) { - activateCategories(nearestListing); - } else { - // See if the referrer is a listing page for this item - const referredRelativePath = offsetAbsoluteUrl(document.referrer); - const referrerListing = listingHrefs.find((listingHref) => { - const isListingReferrer = - listingHref === referredRelativePath || - listingHref === referredRelativePath + "index.html"; - return isListingReferrer; - }); - - if (referrerListing) { - // Try to use the referrer if possible - activateCategories(referrerListing); - } else if (listingHrefs.length > 0) { - // Otherwise, just fall back to the first listing - activateCategories(listingHrefs[0]); - } - } - }); - } - } - if (hasTitleCategories()) { - findAndActivateCategories(); + + - const findNearestParentListing = (href, listingHrefs) => { - if (!href || !listingHrefs) { - return undefined; - } - // Look up the tree for a nearby linting and use that if we find one - const relativeParts = href.substring(1).split("/"); - while (relativeParts.length > 0) { - const path = relativeParts.join("/"); - for (const listingHref of listingHrefs) { - if (listingHref.startsWith(path)) { - return listingHref; - } - } - relativeParts.pop(); - } - return undefined; - }; - const manageSidebarVisiblity = (el, placeholderDescriptor) => { - let isVisible = true; - let elRect; - return (hiddenRegions) => { - if (el === null) { - return; - } - // Find the last element of the TOC - const lastChildEl = el.lastElementChild; - if (lastChildEl) { - // Converts the sidebar to a menu - const convertToMenu = () => { - for (const child of el.children) { - child.style.opacity = 0; - child.style.overflow = "hidden"; - } - nexttick(() => { - const toggleContainer = window.document.createElement("div"); - toggleContainer.style.width = "100%"; - toggleContainer.classList.add("zindex-over-content"); - toggleContainer.classList.add("quarto-sidebar-toggle"); - toggleContainer.classList.add("headroom-target"); // Marks this to be managed by headeroom - toggleContainer.id = placeholderDescriptor.id; - toggleContainer.style.position = "fixed"; - - const toggleIcon = window.document.createElement("i"); - toggleIcon.classList.add("quarto-sidebar-toggle-icon"); - toggleIcon.classList.add("bi"); - toggleIcon.classList.add("bi-caret-down-fill"); - - const toggleTitle = window.document.createElement("div"); - const titleEl = window.document.body.querySelector( - placeholderDescriptor.titleSelector - ); - if (titleEl) { - toggleTitle.append( - titleEl.textContent || titleEl.innerText, - toggleIcon - ); - } - toggleTitle.classList.add("zindex-over-content"); - toggleTitle.classList.add("quarto-sidebar-toggle-title"); - toggleContainer.append(toggleTitle); - - const toggleContents = window.document.createElement("div"); - toggleContents.classList = el.classList; - toggleContents.classList.add("zindex-over-content"); - toggleContents.classList.add("quarto-sidebar-toggle-contents"); - for (const child of el.children) { - if (child.id === "toc-title") { - continue; - } - - const clone = child.cloneNode(true); - clone.style.opacity = 1; - clone.style.display = null; - toggleContents.append(clone); - } - toggleContents.style.height = "0px"; - const positionToggle = () => { - // position the element (top left of parent, same width as parent) - if (!elRect) { - elRect = el.getBoundingClientRect(); - } - toggleContainer.style.left = `${elRect.left}px`; - toggleContainer.style.top = `${elRect.top}px`; - toggleContainer.style.width = `${elRect.width}px`; - }; - positionToggle(); - - toggleContainer.append(toggleContents); - el.parentElement.prepend(toggleContainer); - - // Process clicks - let tocShowing = false; - // Allow the caller to control whether this is dismissed - // when it is clicked (e.g. sidebar navigation supports - // opening and closing the nav tree, so don't dismiss on click) - const clickEl = placeholderDescriptor.dismissOnClick - ? toggleContainer - : toggleTitle; - - const closeToggle = () => { - if (tocShowing) { - toggleContainer.classList.remove("expanded"); - toggleContents.style.height = "0px"; - tocShowing = false; - } - }; - - // Get rid of any expanded toggle if the user scrolls - window.document.addEventListener( - "scroll", - throttle(() => { - closeToggle(); - }, 50) - ); - - // Handle positioning of the toggle - window.addEventListener( - "resize", - throttle(() => { - elRect = undefined; - positionToggle(); - }, 50) - ); - - window.addEventListener("quarto-hrChanged", () => { - elRect = undefined; - }); - - // Process the click - clickEl.onclick = () => { - if (!tocShowing) { - toggleContainer.classList.add("expanded"); - toggleContents.style.height = null; - tocShowing = true; - } else { - closeToggle(); - } - }; - }); - }; - - // Converts a sidebar from a menu back to a sidebar - const convertToSidebar = () => { - for (const child of el.children) { - child.style.opacity = 1; - child.style.overflow = null; - } - const placeholderEl = window.document.getElementById( - placeholderDescriptor.id - ); - if (placeholderEl) { - placeholderEl.remove(); - } - el.classList.remove("rollup"); - }; - - if (isReaderMode()) { - convertToMenu(); - isVisible = false; - } else { - // Find the top and bottom o the element that is being managed - const elTop = el.offsetTop; - const elBottom = - elTop + lastChildEl.offsetTop + lastChildEl.offsetHeight; - - if (!isVisible) { - // If the element is current not visible reveal if there are - // no conflicts with overlay regions - if (!inHiddenRegion(elTop, elBottom, hiddenRegions)) { - convertToSidebar(); - isVisible = true; - } - } else { - // If the element is visible, hide it if it conflicts with overlay regions - // and insert a placeholder toggle (or if we're in reader mode) - if (inHiddenRegion(elTop, elBottom, hiddenRegions)) { - convertToMenu(); - isVisible = false; - } - } - } - } - }; - }; + - const tabEls = document.querySelectorAll('a[data-bs-toggle="tab"]'); - for (const tabEl of tabEls) { - const id = tabEl.getAttribute("data-bs-target"); - if (id) { - const columnEl = document.querySelector( - `${id} .column-margin, .tabset-margin-content` - ); - if (columnEl) - tabEl.addEventListener("shown.bs.tab", function (event) { - const el = event.srcElement; - if (el) { - const visibleCls = `${el.id}-margin-content`; - // walk up until we find a parent tabset - let panelTabsetEl = el.parentElement; - while (panelTabsetEl) { - if (panelTabsetEl.classList.contains("panel-tabset")) { - break; - } - panelTabsetEl = panelTabsetEl.parentElement; - } - - if (panelTabsetEl) { - const prevSib = panelTabsetEl.previousElementSibling; - if ( - prevSib && - prevSib.classList.contains("tabset-margin-container") - ) { - const childNodes = prevSib.querySelectorAll( - ".tabset-margin-content" - ); - for (const childEl of childNodes) { - if (childEl.classList.contains(visibleCls)) { - childEl.classList.remove("collapse"); - } else { - childEl.classList.add("collapse"); - } - } - } - } - } - layoutMarginEls(); - }); - } - } - // Manage the visibility of the toc and the sidebar - const marginScrollVisibility = manageSidebarVisiblity(marginSidebarEl, { - id: "quarto-toc-toggle", - titleSelector: "#toc-title", - dismissOnClick: true, - }); - const sidebarScrollVisiblity = manageSidebarVisiblity(sidebarEl, { - id: "quarto-sidebarnav-toggle", - titleSelector: ".title", - dismissOnClick: false, - }); - let tocLeftScrollVisibility; - if (leftTocEl) { - tocLeftScrollVisibility = manageSidebarVisiblity(leftTocEl, { - id: "quarto-lefttoc-toggle", - titleSelector: "#toc-title", - dismissOnClick: true, - }); - } - - // Find the first element that uses formatting in special columns - const conflictingEls = window.document.body.querySelectorAll( - '[class^="column-"], [class*=" column-"], aside, [class*="margin-caption"], [class*=" margin-caption"], [class*="margin-ref"], [class*=" margin-ref"]' - ); - - // Filter all the possibly conflicting elements into ones - // the do conflict on the left or ride side - const arrConflictingEls = Array.from(conflictingEls); - const leftSideConflictEls = arrConflictingEls.filter((el) => { - if (el.tagName === "ASIDE") { - return false; - } - return Array.from(el.classList).find((className) => { - return ( - className !== "column-body" && - className.startsWith("column-") && - !className.endsWith("right") && - !className.endsWith("container") && - className !== "column-margin" - ); - }); - }); - const rightSideConflictEls = arrConflictingEls.filter((el) => { - if (el.tagName === "ASIDE") { - return true; - } + - const hasMarginCaption = Array.from(el.classList).find((className) => { - return className == "margin-caption"; - }); - if (hasMarginCaption) { - return true; - } - - return Array.from(el.classList).find((className) => { - return ( - className !== "column-body" && - !className.endsWith("container") && - className.startsWith("column-") && - !className.endsWith("left") - ); - }); - }); + - const kOverlapPaddingSize = 10; - function toRegions(els) { - return els.map((el) => { - const boundRect = el.getBoundingClientRect(); - const top = - boundRect.top + - document.documentElement.scrollTop - - kOverlapPaddingSize; - return { - top, - bottom: top + el.scrollHeight + 2 * kOverlapPaddingSize, - }; - }); - } + - let hasObserved = false; - const visibleItemObserver = (els) => { - let visibleElements = [...els]; - const intersectionObserver = new IntersectionObserver( - (entries, _observer) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - if (visibleElements.indexOf(entry.target) === -1) { - visibleElements.push(entry.target); - } - } else { - visibleElements = visibleElements.filter((visibleEntry) => { - return visibleEntry !== entry; - }); - } - }); - if (!hasObserved) { - hideOverlappedSidebars(); - } - hasObserved = true; - }, - {} - ); - els.forEach((el) => { - intersectionObserver.observe(el); - }); - return { - getVisibleEntries: () => { - return visibleElements; - }, - }; - }; - const rightElementObserver = visibleItemObserver(rightSideConflictEls); - const leftElementObserver = visibleItemObserver(leftSideConflictEls); - - const hideOverlappedSidebars = () => { - marginScrollVisibility(toRegions(rightElementObserver.getVisibleEntries())); - sidebarScrollVisiblity(toRegions(leftElementObserver.getVisibleEntries())); - if (tocLeftScrollVisibility) { - tocLeftScrollVisibility( - toRegions(leftElementObserver.getVisibleEntries()) - ); - } - }; + - window.quartoToggleReader = () => { - // Applies a slow class (or removes it) - // to update the transition speed - const slowTransition = (slow) => { - const manageTransition = (id, slow) => { - const el = document.getElementById(id); - if (el) { - if (slow) { - el.classList.add("slow"); - } else { - el.classList.remove("slow"); - } - } - }; + - manageTransition("TOC", slow); - manageTransition("quarto-sidebar", slow); - }; - const readerMode = !isReaderMode(); - setReaderModeValue(readerMode); - - // If we're entering reader mode, slow the transition - if (readerMode) { - slowTransition(readerMode); - } - highlightReaderToggle(readerMode); - hideOverlappedSidebars(); - - // If we're exiting reader mode, restore the non-slow transition - if (!readerMode) { - slowTransition(!readerMode); - } - }; - const highlightReaderToggle = (readerMode) => { - const els = document.querySelectorAll(".quarto-reader-toggle"); - if (els) { - els.forEach((el) => { - if (readerMode) { - el.classList.add("reader"); - } else { - el.classList.remove("reader"); - } - }); - } - }; +
- const setReaderModeValue = (val) => { - if (window.location.protocol !== "file:") { - window.localStorage.setItem("quarto-reader-mode", val); - } else { - localReaderMode = val; - } - }; - const isReaderMode = () => { - if (window.location.protocol !== "file:") { - return window.localStorage.getItem("quarto-reader-mode") === "true"; - } else { - return localReaderMode; - } - }; - let localReaderMode = null; - - const tocOpenDepthStr = tocEl?.getAttribute("data-toc-expanded"); - const tocOpenDepth = tocOpenDepthStr ? Number(tocOpenDepthStr) : 1; - - // Walk the TOC and collapse/expand nodes - // Nodes are expanded if: - // - they are top level - // - they have children that are 'active' links - // - they are directly below an link that is 'active' - const walk = (el, depth) => { - // Tick depth when we enter a UL - if (el.tagName === "UL") { - depth = depth + 1; - } - - // It this is active link - let isActiveNode = false; - if (el.tagName === "A" && el.classList.contains("active")) { - isActiveNode = true; - } - - // See if there is an active child to this element - let hasActiveChild = false; - for (child of el.children) { - hasActiveChild = walk(child, depth) || hasActiveChild; - } - - // Process the collapse state if this is an UL - if (el.tagName === "UL") { - if (tocOpenDepth === -1 && depth > 1) { - el.classList.add("collapse"); - } else if ( - depth <= tocOpenDepth || - hasActiveChild || - prevSiblingIsActiveLink(el) - ) { - el.classList.remove("collapse"); - } else { - el.classList.add("collapse"); - } - // untick depth when we leave a UL - depth = depth - 1; - } - return hasActiveChild || isActiveNode; - }; - // walk the TOC and expand / collapse any items that should be shown + - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } +
## i Loading crmPack
+
## [1] "CohortSizeConst"
+

A constant size of 3 participants.

- function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); +
-function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; -} + - - - - - - - - - - - - - - -
- -
-
-
-

Test

-
- - - -
+ - - - -
- - -
- -
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeConst"
-
-
-

A constant size of 3 participants

-
-
+ -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html index 0a27e4492..f1bae7849 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html @@ -1,3290 +1,456 @@ - - - + - + + + + -Test - - - - - + + + + + + + + + + - // walk the TOC and expand / collapse any items that should be shown + - if (tocEl) { - walk(tocEl, 0); - updateActiveLink(); + + - // Throttle the scroll event and walk peridiocally - window.document.addEventListener( - "scroll", - throttle(() => { - if (tocEl) { - updateActiveLink(); - walk(tocEl, 0); - } - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 5) - ); - window.addEventListener( - "resize", - throttle(() => { - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 10) - ); - hideOverlappedSidebars(); - highlightReaderToggle(isReaderMode()); -}); -// grouped tabsets -window.addEventListener("pageshow", (_event) => { - function getTabSettings() { - const data = localStorage.getItem("quarto-persistent-tabsets-data"); - if (!data) { - localStorage.setItem("quarto-persistent-tabsets-data", "{}"); - return {}; - } - if (data) { - return JSON.parse(data); - } - } - function setTabSettings(data) { - localStorage.setItem( - "quarto-persistent-tabsets-data", - JSON.stringify(data) - ); - } - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } - function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); -function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; + -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Popper={})}(this,(function(e){"use strict";function t(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function n(e){return e instanceof t(e).Element||e instanceof Element}function r(e){return e instanceof t(e).HTMLElement||e instanceof HTMLElement}function o(e){return"undefined"!=typeof ShadowRoot&&(e instanceof t(e).ShadowRoot||e instanceof ShadowRoot)}var i=Math.max,a=Math.min,s=Math.round;function f(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),o=1,i=1;if(r(e)&&t){var a=e.offsetHeight,f=e.offsetWidth;f>0&&(o=s(n.width)/f||1),a>0&&(i=s(n.height)/a||1)}return{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function c(e){var n=t(e);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function p(e){return e?(e.nodeName||"").toLowerCase():null}function u(e){return((n(e)?e.ownerDocument:e.document)||window.document).documentElement}function l(e){return f(u(e)).left+c(e).scrollLeft}function d(e){return t(e).getComputedStyle(e)}function h(e){var t=d(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function m(e,n,o){void 0===o&&(o=!1);var i,a,d=r(n),m=r(n)&&function(e){var t=e.getBoundingClientRect(),n=s(t.width)/e.offsetWidth||1,r=s(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(n),v=u(n),g=f(e,m),y={scrollLeft:0,scrollTop:0},b={x:0,y:0};return(d||!d&&!o)&&(("body"!==p(n)||h(v))&&(y=(i=n)!==t(i)&&r(i)?{scrollLeft:(a=i).scrollLeft,scrollTop:a.scrollTop}:c(i)),r(n)?((b=f(n,!0)).x+=n.clientLeft,b.y+=n.clientTop):v&&(b.x=l(v))),{x:g.left+y.scrollLeft-b.x,y:g.top+y.scrollTop-b.y,width:g.width,height:g.height}}function v(e){var t=f(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function g(e){return"html"===p(e)?e:e.assignedSlot||e.parentNode||(o(e)?e.host:null)||u(e)}function y(e){return["html","body","#document"].indexOf(p(e))>=0?e.ownerDocument.body:r(e)&&h(e)?e:y(g(e))}function b(e,n){var r;void 0===n&&(n=[]);var o=y(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=t(o),s=i?[a].concat(a.visualViewport||[],h(o)?o:[]):o,f=n.concat(s);return i?f:f.concat(b(g(s)))}function x(e){return["table","td","th"].indexOf(p(e))>=0}function w(e){return r(e)&&"fixed"!==d(e).position?e.offsetParent:null}function O(e){for(var n=t(e),i=w(e);i&&x(i)&&"static"===d(i).position;)i=w(i);return i&&("html"===p(i)||"body"===p(i)&&"static"===d(i).position)?n:i||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&r(e)&&"fixed"===d(e).position)return null;var n=g(e);for(o(n)&&(n=n.host);r(n)&&["html","body"].indexOf(p(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||n}var j="top",E="bottom",D="right",A="left",L="auto",P=[j,E,D,A],M="start",k="end",W="viewport",B="popper",H=P.reduce((function(e,t){return e.concat([t+"-"+M,t+"-"+k])}),[]),T=[].concat(P,[L]).reduce((function(e,t){return e.concat([t,t+"-"+M,t+"-"+k])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function S(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||o(e)})),r}function C(e){return e.split("-")[0]}function q(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function V(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function N(e,r){return r===W?V(function(e){var n=t(e),r=u(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;return o&&(i=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,f=o.offsetTop)),{width:i,height:a,x:s+l(e),y:f}}(e)):n(r)?function(e){var t=f(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(r):V(function(e){var t,n=u(e),r=c(e),o=null==(t=e.ownerDocument)?void 0:t.body,a=i(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=i(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+l(e),p=-r.scrollTop;return"rtl"===d(o||n).direction&&(f+=i(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:f,y:p}}(u(e)))}function I(e,t,o){var s="clippingParents"===t?function(e){var t=b(g(e)),o=["absolute","fixed"].indexOf(d(e).position)>=0&&r(e)?O(e):e;return n(o)?t.filter((function(e){return n(e)&&q(e,o)&&"body"!==p(e)})):[]}(e):[].concat(t),f=[].concat(s,[o]),c=f[0],u=f.reduce((function(t,n){var r=N(e,n);return t.top=i(r.top,t.top),t.right=a(r.right,t.right),t.bottom=a(r.bottom,t.bottom),t.left=i(r.left,t.left),t}),N(e,c));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function _(e){return e.split("-")[1]}function F(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function U(e){var t,n=e.reference,r=e.element,o=e.placement,i=o?C(o):null,a=o?_(o):null,s=n.x+n.width/2-r.width/2,f=n.y+n.height/2-r.height/2;switch(i){case j:t={x:s,y:n.y-r.height};break;case E:t={x:s,y:n.y+n.height};break;case D:t={x:n.x+n.width,y:f};break;case A:t={x:n.x-r.width,y:f};break;default:t={x:n.x,y:n.y}}var c=i?F(i):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case M:t[c]=t[c]-(n[p]/2-r[p]/2);break;case k:t[c]=t[c]+(n[p]/2-r[p]/2)}}return t}function z(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Y(e,t){void 0===t&&(t={});var r=t,o=r.placement,i=void 0===o?e.placement:o,a=r.boundary,s=void 0===a?"clippingParents":a,c=r.rootBoundary,p=void 0===c?W:c,l=r.elementContext,d=void 0===l?B:l,h=r.altBoundary,m=void 0!==h&&h,v=r.padding,g=void 0===v?0:v,y=z("number"!=typeof g?g:X(g,P)),b=d===B?"reference":B,x=e.rects.popper,w=e.elements[m?b:d],O=I(n(w)?w:w.contextElement||u(e.elements.popper),s,p),A=f(e.elements.reference),L=U({reference:A,element:x,strategy:"absolute",placement:i}),M=V(Object.assign({},x,L)),k=d===B?M:A,H={top:O.top-k.top+y.top,bottom:k.bottom-O.bottom+y.bottom,left:O.left-k.left+y.left,right:k.right-O.right+y.right},T=e.modifiersData.offset;if(d===B&&T){var R=T[i];Object.keys(H).forEach((function(e){var t=[D,E].indexOf(e)>=0?1:-1,n=[j,E].indexOf(e)>=0?"y":"x";H[e]+=R[n]*t}))}return H}var G={placement:"bottom",modifiers:[],strategy:"absolute"};function J(){for(var e=arguments.length,t=new Array(e),n=0;n=0?-1:1,i="function"==typeof n?n(Object.assign({},t,{placement:e})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[A,D].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,i),e}),{}),s=a[t.placement],f=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},ie={left:"right",right:"left",bottom:"top",top:"bottom"};function ae(e){return e.replace(/left|right|bottom|top/g,(function(e){return ie[e]}))}var se={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return se[e]}))}function ce(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=void 0===f?T:f,p=_(r),u=p?s?H:H.filter((function(e){return _(e)===p})):P,l=u.filter((function(e){return c.indexOf(e)>=0}));0===l.length&&(l=u);var d=l.reduce((function(t,n){return t[n]=Y(e,{placement:n,boundary:o,rootBoundary:i,padding:a})[C(n)],t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}var pe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0===a||a,f=n.fallbackPlacements,c=n.padding,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.flipVariations,h=void 0===d||d,m=n.allowedAutoPlacements,v=t.options.placement,g=C(v),y=f||(g===v||!h?[ae(v)]:function(e){if(C(e)===L)return[];var t=ae(e);return[fe(e),t,fe(t)]}(v)),b=[v].concat(y).reduce((function(e,n){return e.concat(C(n)===L?ce(t,{placement:n,boundary:p,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,O=new Map,P=!0,k=b[0],W=0;W=0,S=R?"width":"height",q=Y(t,{placement:B,boundary:p,rootBoundary:u,altBoundary:l,padding:c}),V=R?T?D:A:T?E:j;x[S]>w[S]&&(V=ae(V));var N=ae(V),I=[];if(i&&I.push(q[H]<=0),s&&I.push(q[V]<=0,q[N]<=0),I.every((function(e){return e}))){k=B,P=!1;break}O.set(B,I)}if(P)for(var F=function(e){var t=b.find((function(t){var n=O.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return k=t,"break"},U=h?3:1;U>0;U--){if("break"===F(U))break}t.placement!==k&&(t.modifiersData[r]._skip=!0,t.placement=k,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ue(e,t,n){return i(e,a(t,n))}var le={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=void 0===o||o,f=n.altAxis,c=void 0!==f&&f,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,h=n.tether,m=void 0===h||h,g=n.tetherOffset,y=void 0===g?0:g,b=Y(t,{boundary:p,rootBoundary:u,padding:d,altBoundary:l}),x=C(t.placement),w=_(t.placement),L=!w,P=F(x),k="x"===P?"y":"x",W=t.modifiersData.popperOffsets,B=t.rects.reference,H=t.rects.popper,T="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,R="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,q={x:0,y:0};if(W){if(s){var V,N="y"===P?j:A,I="y"===P?E:D,U="y"===P?"height":"width",z=W[P],X=z+b[N],G=z-b[I],J=m?-H[U]/2:0,K=w===M?B[U]:H[U],Q=w===M?-H[U]:-B[U],Z=t.elements.arrow,$=m&&Z?v(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[N],ne=ee[I],re=ue(0,B[U],$[U]),oe=L?B[U]/2-J-re-te-R.mainAxis:K-re-te-R.mainAxis,ie=L?-B[U]/2+J+re+ne+R.mainAxis:Q+re+ne+R.mainAxis,ae=t.elements.arrow&&O(t.elements.arrow),se=ae?"y"===P?ae.clientTop||0:ae.clientLeft||0:0,fe=null!=(V=null==S?void 0:S[P])?V:0,ce=z+ie-fe,pe=ue(m?a(X,z+oe-fe-se):X,z,m?i(G,ce):G);W[P]=pe,q[P]=pe-z}if(c){var le,de="x"===P?j:A,he="x"===P?E:D,me=W[k],ve="y"===k?"height":"width",ge=me+b[de],ye=me-b[he],be=-1!==[j,A].indexOf(x),xe=null!=(le=null==S?void 0:S[k])?le:0,we=be?ge:me-B[ve]-H[ve]-xe+R.altAxis,Oe=be?me+B[ve]+H[ve]-xe-R.altAxis:ye,je=m&&be?function(e,t,n){var r=ue(e,t,n);return r>n?n:r}(we,me,Oe):ue(m?we:ge,me,m?Oe:ye);W[k]=je,q[k]=je-me}t.modifiersData[r]=q}},requiresIfExists:["offset"]};var de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,o=e.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=C(n.placement),f=F(s),c=[A,D].indexOf(s)>=0?"height":"width";if(i&&a){var p=function(e,t){return z("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,P))}(o.padding,n),u=v(i),l="y"===f?j:A,d="y"===f?E:D,h=n.rects.reference[c]+n.rects.reference[f]-a[f]-n.rects.popper[c],m=a[f]-n.rects.reference[f],g=O(i),y=g?"y"===f?g.clientHeight||0:g.clientWidth||0:0,b=h/2-m/2,x=p[l],w=y-u[c]-p[d],L=y/2-u[c]/2+b,M=ue(x,L,w),k=f;n.modifiersData[r]=((t={})[k]=M,t.centerOffset=M-L,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&q(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function he(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function me(e){return[j,D,E,A].some((function(t){return e[t]>=0}))}var ve={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=Y(t,{elementContext:"reference"}),s=Y(t,{altBoundary:!0}),f=he(a,r),c=he(s,o,i),p=me(f),u=me(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},ge=K({defaultModifiers:[Z,$,ne,re]}),ye=[Z,$,ne,re,oe,pe,le,de,ve],be=K({defaultModifiers:ye});e.applyStyles=re,e.arrow=de,e.computeStyles=ne,e.createPopper=be,e.createPopperLite=ge,e.defaultModifiers=ye,e.detectOverflow=Y,e.eventListeners=Z,e.flip=pe,e.hide=ve,e.offset=oe,e.popperGenerator=K,e.popperOffsets=$,e.preventOverflow=le,Object.defineProperty(e,"__esModule",{value:!0})})); - - - - - - - - + + + + - + -
-
+
-
-
-

Test

-
-
+ - -
-
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeDLT"
+

Test

+
-
- - ----- + + +
## i Loading crmPack
+
## [1] "CohortSizeDLT"
+
Defined by the number of DLTs so far observed
+ - - + - + + + - - - - + + + + - - - - + + + + - - - - + + + +
+Defined by the number of DLTs so far observed +
+
+
No of DLTs -
+
LowerUpperCohort size
+Lower + +Upper + +Cohort size +
011
+0 + +1 + +1 +
1Inf3
+1 + +Inf + +3 +
-
+ + + +
-
- - + + + + -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html index 30a9cb0ce..f74cef1e0 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html @@ -1,3019 +1,361 @@ - - - + - + + + + -Test - - - - - + + + + + + + + + + - // walk the TOC and expand / collapse any items that should be shown + - if (tocEl) { - walk(tocEl, 0); - updateActiveLink(); + + - // Throttle the scroll event and walk peridiocally - window.document.addEventListener( - "scroll", - throttle(() => { - if (tocEl) { - updateActiveLink(); - walk(tocEl, 0); - } - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 5) - ); - window.addEventListener( - "resize", - throttle(() => { - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 10) - ); - hideOverlappedSidebars(); - highlightReaderToggle(isReaderMode()); -}); - -// grouped tabsets -window.addEventListener("pageshow", (_event) => { - function getTabSettings() { - const data = localStorage.getItem("quarto-persistent-tabsets-data"); - if (!data) { - localStorage.setItem("quarto-persistent-tabsets-data", "{}"); - return {}; - } - if (data) { - return JSON.parse(data); - } - } - function setTabSettings(data) { - localStorage.setItem( - "quarto-persistent-tabsets-data", - JSON.stringify(data) - ); - } - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } - function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); -function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; + -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Popper={})}(this,(function(e){"use strict";function t(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function n(e){return e instanceof t(e).Element||e instanceof Element}function r(e){return e instanceof t(e).HTMLElement||e instanceof HTMLElement}function o(e){return"undefined"!=typeof ShadowRoot&&(e instanceof t(e).ShadowRoot||e instanceof ShadowRoot)}var i=Math.max,a=Math.min,s=Math.round;function f(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),o=1,i=1;if(r(e)&&t){var a=e.offsetHeight,f=e.offsetWidth;f>0&&(o=s(n.width)/f||1),a>0&&(i=s(n.height)/a||1)}return{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function c(e){var n=t(e);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function p(e){return e?(e.nodeName||"").toLowerCase():null}function u(e){return((n(e)?e.ownerDocument:e.document)||window.document).documentElement}function l(e){return f(u(e)).left+c(e).scrollLeft}function d(e){return t(e).getComputedStyle(e)}function h(e){var t=d(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function m(e,n,o){void 0===o&&(o=!1);var i,a,d=r(n),m=r(n)&&function(e){var t=e.getBoundingClientRect(),n=s(t.width)/e.offsetWidth||1,r=s(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(n),v=u(n),g=f(e,m),y={scrollLeft:0,scrollTop:0},b={x:0,y:0};return(d||!d&&!o)&&(("body"!==p(n)||h(v))&&(y=(i=n)!==t(i)&&r(i)?{scrollLeft:(a=i).scrollLeft,scrollTop:a.scrollTop}:c(i)),r(n)?((b=f(n,!0)).x+=n.clientLeft,b.y+=n.clientTop):v&&(b.x=l(v))),{x:g.left+y.scrollLeft-b.x,y:g.top+y.scrollTop-b.y,width:g.width,height:g.height}}function v(e){var t=f(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function g(e){return"html"===p(e)?e:e.assignedSlot||e.parentNode||(o(e)?e.host:null)||u(e)}function y(e){return["html","body","#document"].indexOf(p(e))>=0?e.ownerDocument.body:r(e)&&h(e)?e:y(g(e))}function b(e,n){var r;void 0===n&&(n=[]);var o=y(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=t(o),s=i?[a].concat(a.visualViewport||[],h(o)?o:[]):o,f=n.concat(s);return i?f:f.concat(b(g(s)))}function x(e){return["table","td","th"].indexOf(p(e))>=0}function w(e){return r(e)&&"fixed"!==d(e).position?e.offsetParent:null}function O(e){for(var n=t(e),i=w(e);i&&x(i)&&"static"===d(i).position;)i=w(i);return i&&("html"===p(i)||"body"===p(i)&&"static"===d(i).position)?n:i||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&r(e)&&"fixed"===d(e).position)return null;var n=g(e);for(o(n)&&(n=n.host);r(n)&&["html","body"].indexOf(p(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||n}var j="top",E="bottom",D="right",A="left",L="auto",P=[j,E,D,A],M="start",k="end",W="viewport",B="popper",H=P.reduce((function(e,t){return e.concat([t+"-"+M,t+"-"+k])}),[]),T=[].concat(P,[L]).reduce((function(e,t){return e.concat([t,t+"-"+M,t+"-"+k])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function S(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||o(e)})),r}function C(e){return e.split("-")[0]}function q(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function V(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function N(e,r){return r===W?V(function(e){var n=t(e),r=u(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;return o&&(i=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,f=o.offsetTop)),{width:i,height:a,x:s+l(e),y:f}}(e)):n(r)?function(e){var t=f(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(r):V(function(e){var t,n=u(e),r=c(e),o=null==(t=e.ownerDocument)?void 0:t.body,a=i(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=i(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+l(e),p=-r.scrollTop;return"rtl"===d(o||n).direction&&(f+=i(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:f,y:p}}(u(e)))}function I(e,t,o){var s="clippingParents"===t?function(e){var t=b(g(e)),o=["absolute","fixed"].indexOf(d(e).position)>=0&&r(e)?O(e):e;return n(o)?t.filter((function(e){return n(e)&&q(e,o)&&"body"!==p(e)})):[]}(e):[].concat(t),f=[].concat(s,[o]),c=f[0],u=f.reduce((function(t,n){var r=N(e,n);return t.top=i(r.top,t.top),t.right=a(r.right,t.right),t.bottom=a(r.bottom,t.bottom),t.left=i(r.left,t.left),t}),N(e,c));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function _(e){return e.split("-")[1]}function F(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function U(e){var t,n=e.reference,r=e.element,o=e.placement,i=o?C(o):null,a=o?_(o):null,s=n.x+n.width/2-r.width/2,f=n.y+n.height/2-r.height/2;switch(i){case j:t={x:s,y:n.y-r.height};break;case E:t={x:s,y:n.y+n.height};break;case D:t={x:n.x+n.width,y:f};break;case A:t={x:n.x-r.width,y:f};break;default:t={x:n.x,y:n.y}}var c=i?F(i):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case M:t[c]=t[c]-(n[p]/2-r[p]/2);break;case k:t[c]=t[c]+(n[p]/2-r[p]/2)}}return t}function z(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Y(e,t){void 0===t&&(t={});var r=t,o=r.placement,i=void 0===o?e.placement:o,a=r.boundary,s=void 0===a?"clippingParents":a,c=r.rootBoundary,p=void 0===c?W:c,l=r.elementContext,d=void 0===l?B:l,h=r.altBoundary,m=void 0!==h&&h,v=r.padding,g=void 0===v?0:v,y=z("number"!=typeof g?g:X(g,P)),b=d===B?"reference":B,x=e.rects.popper,w=e.elements[m?b:d],O=I(n(w)?w:w.contextElement||u(e.elements.popper),s,p),A=f(e.elements.reference),L=U({reference:A,element:x,strategy:"absolute",placement:i}),M=V(Object.assign({},x,L)),k=d===B?M:A,H={top:O.top-k.top+y.top,bottom:k.bottom-O.bottom+y.bottom,left:O.left-k.left+y.left,right:k.right-O.right+y.right},T=e.modifiersData.offset;if(d===B&&T){var R=T[i];Object.keys(H).forEach((function(e){var t=[D,E].indexOf(e)>=0?1:-1,n=[j,E].indexOf(e)>=0?"y":"x";H[e]+=R[n]*t}))}return H}var G={placement:"bottom",modifiers:[],strategy:"absolute"};function J(){for(var e=arguments.length,t=new Array(e),n=0;n=0?-1:1,i="function"==typeof n?n(Object.assign({},t,{placement:e})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[A,D].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,i),e}),{}),s=a[t.placement],f=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},ie={left:"right",right:"left",bottom:"top",top:"bottom"};function ae(e){return e.replace(/left|right|bottom|top/g,(function(e){return ie[e]}))}var se={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return se[e]}))}function ce(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=void 0===f?T:f,p=_(r),u=p?s?H:H.filter((function(e){return _(e)===p})):P,l=u.filter((function(e){return c.indexOf(e)>=0}));0===l.length&&(l=u);var d=l.reduce((function(t,n){return t[n]=Y(e,{placement:n,boundary:o,rootBoundary:i,padding:a})[C(n)],t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}var pe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0===a||a,f=n.fallbackPlacements,c=n.padding,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.flipVariations,h=void 0===d||d,m=n.allowedAutoPlacements,v=t.options.placement,g=C(v),y=f||(g===v||!h?[ae(v)]:function(e){if(C(e)===L)return[];var t=ae(e);return[fe(e),t,fe(t)]}(v)),b=[v].concat(y).reduce((function(e,n){return e.concat(C(n)===L?ce(t,{placement:n,boundary:p,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,O=new Map,P=!0,k=b[0],W=0;W=0,S=R?"width":"height",q=Y(t,{placement:B,boundary:p,rootBoundary:u,altBoundary:l,padding:c}),V=R?T?D:A:T?E:j;x[S]>w[S]&&(V=ae(V));var N=ae(V),I=[];if(i&&I.push(q[H]<=0),s&&I.push(q[V]<=0,q[N]<=0),I.every((function(e){return e}))){k=B,P=!1;break}O.set(B,I)}if(P)for(var F=function(e){var t=b.find((function(t){var n=O.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return k=t,"break"},U=h?3:1;U>0;U--){if("break"===F(U))break}t.placement!==k&&(t.modifiersData[r]._skip=!0,t.placement=k,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ue(e,t,n){return i(e,a(t,n))}var le={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=void 0===o||o,f=n.altAxis,c=void 0!==f&&f,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,h=n.tether,m=void 0===h||h,g=n.tetherOffset,y=void 0===g?0:g,b=Y(t,{boundary:p,rootBoundary:u,padding:d,altBoundary:l}),x=C(t.placement),w=_(t.placement),L=!w,P=F(x),k="x"===P?"y":"x",W=t.modifiersData.popperOffsets,B=t.rects.reference,H=t.rects.popper,T="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,R="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,q={x:0,y:0};if(W){if(s){var V,N="y"===P?j:A,I="y"===P?E:D,U="y"===P?"height":"width",z=W[P],X=z+b[N],G=z-b[I],J=m?-H[U]/2:0,K=w===M?B[U]:H[U],Q=w===M?-H[U]:-B[U],Z=t.elements.arrow,$=m&&Z?v(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[N],ne=ee[I],re=ue(0,B[U],$[U]),oe=L?B[U]/2-J-re-te-R.mainAxis:K-re-te-R.mainAxis,ie=L?-B[U]/2+J+re+ne+R.mainAxis:Q+re+ne+R.mainAxis,ae=t.elements.arrow&&O(t.elements.arrow),se=ae?"y"===P?ae.clientTop||0:ae.clientLeft||0:0,fe=null!=(V=null==S?void 0:S[P])?V:0,ce=z+ie-fe,pe=ue(m?a(X,z+oe-fe-se):X,z,m?i(G,ce):G);W[P]=pe,q[P]=pe-z}if(c){var le,de="x"===P?j:A,he="x"===P?E:D,me=W[k],ve="y"===k?"height":"width",ge=me+b[de],ye=me-b[he],be=-1!==[j,A].indexOf(x),xe=null!=(le=null==S?void 0:S[k])?le:0,we=be?ge:me-B[ve]-H[ve]-xe+R.altAxis,Oe=be?me+B[ve]+H[ve]-xe-R.altAxis:ye,je=m&&be?function(e,t,n){var r=ue(e,t,n);return r>n?n:r}(we,me,Oe):ue(m?we:ge,me,m?Oe:ye);W[k]=je,q[k]=je-me}t.modifiersData[r]=q}},requiresIfExists:["offset"]};var de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,o=e.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=C(n.placement),f=F(s),c=[A,D].indexOf(s)>=0?"height":"width";if(i&&a){var p=function(e,t){return z("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,P))}(o.padding,n),u=v(i),l="y"===f?j:A,d="y"===f?E:D,h=n.rects.reference[c]+n.rects.reference[f]-a[f]-n.rects.popper[c],m=a[f]-n.rects.reference[f],g=O(i),y=g?"y"===f?g.clientHeight||0:g.clientWidth||0:0,b=h/2-m/2,x=p[l],w=y-u[c]-p[d],L=y/2-u[c]/2+b,M=ue(x,L,w),k=f;n.modifiersData[r]=((t={})[k]=M,t.centerOffset=M-L,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&q(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function he(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function me(e){return[j,D,E,A].some((function(t){return e[t]>=0}))}var ve={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=Y(t,{elementContext:"reference"}),s=Y(t,{altBoundary:!0}),f=he(a,r),c=he(s,o,i),p=me(f),u=me(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},ge=K({defaultModifiers:[Z,$,ne,re]}),ye=[Z,$,ne,re,oe,pe,le,de,ve],be=K({defaultModifiers:ye});e.applyStyles=re,e.arrow=de,e.computeStyles=ne,e.createPopper=be,e.createPopperLite=ge,e.defaultModifiers=ye,e.detectOverflow=Y,e.eventListeners=Z,e.flip=pe,e.hide=ve,e.offset=oe,e.popperGenerator=K,e.popperOffsets=$,e.preventOverflow=le,Object.defineProperty(e,"__esModule",{value:!0})})); - - - - - - - - + + + + - + -
-
+
-
-
-

Test

-
-
+ - -
-
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeMax"
+

Test

+
-
-The maximum of the cohort sizes defined in the following rules: + +
## i Loading crmPack
+
## [1] "CohortSizeMax"
+The maximum of the cohort sizes defined in the following rules:
Defined by the dose to be used in the next cohort @@ -3064,7 +406,6 @@

Test

-
@@ -3116,248 +457,52 @@

Test

-
-
+ + + +
-
- - + + + + -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html index 4d40b7d3e..fe4dfe8ee 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html @@ -1,3019 +1,361 @@ - - - + - + + + + -Test - - - - - + + + + + + + + + + - // walk the TOC and expand / collapse any items that should be shown + - if (tocEl) { - walk(tocEl, 0); - updateActiveLink(); + + - // Throttle the scroll event and walk peridiocally - window.document.addEventListener( - "scroll", - throttle(() => { - if (tocEl) { - updateActiveLink(); - walk(tocEl, 0); - } - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 5) - ); - window.addEventListener( - "resize", - throttle(() => { - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 10) - ); - hideOverlappedSidebars(); - highlightReaderToggle(isReaderMode()); -}); - -// grouped tabsets -window.addEventListener("pageshow", (_event) => { - function getTabSettings() { - const data = localStorage.getItem("quarto-persistent-tabsets-data"); - if (!data) { - localStorage.setItem("quarto-persistent-tabsets-data", "{}"); - return {}; - } - if (data) { - return JSON.parse(data); - } - } - function setTabSettings(data) { - localStorage.setItem( - "quarto-persistent-tabsets-data", - JSON.stringify(data) - ); - } - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } - function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); -function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; + -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Popper={})}(this,(function(e){"use strict";function t(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function n(e){return e instanceof t(e).Element||e instanceof Element}function r(e){return e instanceof t(e).HTMLElement||e instanceof HTMLElement}function o(e){return"undefined"!=typeof ShadowRoot&&(e instanceof t(e).ShadowRoot||e instanceof ShadowRoot)}var i=Math.max,a=Math.min,s=Math.round;function f(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),o=1,i=1;if(r(e)&&t){var a=e.offsetHeight,f=e.offsetWidth;f>0&&(o=s(n.width)/f||1),a>0&&(i=s(n.height)/a||1)}return{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function c(e){var n=t(e);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function p(e){return e?(e.nodeName||"").toLowerCase():null}function u(e){return((n(e)?e.ownerDocument:e.document)||window.document).documentElement}function l(e){return f(u(e)).left+c(e).scrollLeft}function d(e){return t(e).getComputedStyle(e)}function h(e){var t=d(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function m(e,n,o){void 0===o&&(o=!1);var i,a,d=r(n),m=r(n)&&function(e){var t=e.getBoundingClientRect(),n=s(t.width)/e.offsetWidth||1,r=s(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(n),v=u(n),g=f(e,m),y={scrollLeft:0,scrollTop:0},b={x:0,y:0};return(d||!d&&!o)&&(("body"!==p(n)||h(v))&&(y=(i=n)!==t(i)&&r(i)?{scrollLeft:(a=i).scrollLeft,scrollTop:a.scrollTop}:c(i)),r(n)?((b=f(n,!0)).x+=n.clientLeft,b.y+=n.clientTop):v&&(b.x=l(v))),{x:g.left+y.scrollLeft-b.x,y:g.top+y.scrollTop-b.y,width:g.width,height:g.height}}function v(e){var t=f(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function g(e){return"html"===p(e)?e:e.assignedSlot||e.parentNode||(o(e)?e.host:null)||u(e)}function y(e){return["html","body","#document"].indexOf(p(e))>=0?e.ownerDocument.body:r(e)&&h(e)?e:y(g(e))}function b(e,n){var r;void 0===n&&(n=[]);var o=y(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=t(o),s=i?[a].concat(a.visualViewport||[],h(o)?o:[]):o,f=n.concat(s);return i?f:f.concat(b(g(s)))}function x(e){return["table","td","th"].indexOf(p(e))>=0}function w(e){return r(e)&&"fixed"!==d(e).position?e.offsetParent:null}function O(e){for(var n=t(e),i=w(e);i&&x(i)&&"static"===d(i).position;)i=w(i);return i&&("html"===p(i)||"body"===p(i)&&"static"===d(i).position)?n:i||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&r(e)&&"fixed"===d(e).position)return null;var n=g(e);for(o(n)&&(n=n.host);r(n)&&["html","body"].indexOf(p(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||n}var j="top",E="bottom",D="right",A="left",L="auto",P=[j,E,D,A],M="start",k="end",W="viewport",B="popper",H=P.reduce((function(e,t){return e.concat([t+"-"+M,t+"-"+k])}),[]),T=[].concat(P,[L]).reduce((function(e,t){return e.concat([t,t+"-"+M,t+"-"+k])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function S(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||o(e)})),r}function C(e){return e.split("-")[0]}function q(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function V(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function N(e,r){return r===W?V(function(e){var n=t(e),r=u(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;return o&&(i=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,f=o.offsetTop)),{width:i,height:a,x:s+l(e),y:f}}(e)):n(r)?function(e){var t=f(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(r):V(function(e){var t,n=u(e),r=c(e),o=null==(t=e.ownerDocument)?void 0:t.body,a=i(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=i(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+l(e),p=-r.scrollTop;return"rtl"===d(o||n).direction&&(f+=i(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:f,y:p}}(u(e)))}function I(e,t,o){var s="clippingParents"===t?function(e){var t=b(g(e)),o=["absolute","fixed"].indexOf(d(e).position)>=0&&r(e)?O(e):e;return n(o)?t.filter((function(e){return n(e)&&q(e,o)&&"body"!==p(e)})):[]}(e):[].concat(t),f=[].concat(s,[o]),c=f[0],u=f.reduce((function(t,n){var r=N(e,n);return t.top=i(r.top,t.top),t.right=a(r.right,t.right),t.bottom=a(r.bottom,t.bottom),t.left=i(r.left,t.left),t}),N(e,c));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function _(e){return e.split("-")[1]}function F(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function U(e){var t,n=e.reference,r=e.element,o=e.placement,i=o?C(o):null,a=o?_(o):null,s=n.x+n.width/2-r.width/2,f=n.y+n.height/2-r.height/2;switch(i){case j:t={x:s,y:n.y-r.height};break;case E:t={x:s,y:n.y+n.height};break;case D:t={x:n.x+n.width,y:f};break;case A:t={x:n.x-r.width,y:f};break;default:t={x:n.x,y:n.y}}var c=i?F(i):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case M:t[c]=t[c]-(n[p]/2-r[p]/2);break;case k:t[c]=t[c]+(n[p]/2-r[p]/2)}}return t}function z(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Y(e,t){void 0===t&&(t={});var r=t,o=r.placement,i=void 0===o?e.placement:o,a=r.boundary,s=void 0===a?"clippingParents":a,c=r.rootBoundary,p=void 0===c?W:c,l=r.elementContext,d=void 0===l?B:l,h=r.altBoundary,m=void 0!==h&&h,v=r.padding,g=void 0===v?0:v,y=z("number"!=typeof g?g:X(g,P)),b=d===B?"reference":B,x=e.rects.popper,w=e.elements[m?b:d],O=I(n(w)?w:w.contextElement||u(e.elements.popper),s,p),A=f(e.elements.reference),L=U({reference:A,element:x,strategy:"absolute",placement:i}),M=V(Object.assign({},x,L)),k=d===B?M:A,H={top:O.top-k.top+y.top,bottom:k.bottom-O.bottom+y.bottom,left:O.left-k.left+y.left,right:k.right-O.right+y.right},T=e.modifiersData.offset;if(d===B&&T){var R=T[i];Object.keys(H).forEach((function(e){var t=[D,E].indexOf(e)>=0?1:-1,n=[j,E].indexOf(e)>=0?"y":"x";H[e]+=R[n]*t}))}return H}var G={placement:"bottom",modifiers:[],strategy:"absolute"};function J(){for(var e=arguments.length,t=new Array(e),n=0;n=0?-1:1,i="function"==typeof n?n(Object.assign({},t,{placement:e})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[A,D].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,i),e}),{}),s=a[t.placement],f=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},ie={left:"right",right:"left",bottom:"top",top:"bottom"};function ae(e){return e.replace(/left|right|bottom|top/g,(function(e){return ie[e]}))}var se={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return se[e]}))}function ce(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=void 0===f?T:f,p=_(r),u=p?s?H:H.filter((function(e){return _(e)===p})):P,l=u.filter((function(e){return c.indexOf(e)>=0}));0===l.length&&(l=u);var d=l.reduce((function(t,n){return t[n]=Y(e,{placement:n,boundary:o,rootBoundary:i,padding:a})[C(n)],t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}var pe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0===a||a,f=n.fallbackPlacements,c=n.padding,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.flipVariations,h=void 0===d||d,m=n.allowedAutoPlacements,v=t.options.placement,g=C(v),y=f||(g===v||!h?[ae(v)]:function(e){if(C(e)===L)return[];var t=ae(e);return[fe(e),t,fe(t)]}(v)),b=[v].concat(y).reduce((function(e,n){return e.concat(C(n)===L?ce(t,{placement:n,boundary:p,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,O=new Map,P=!0,k=b[0],W=0;W=0,S=R?"width":"height",q=Y(t,{placement:B,boundary:p,rootBoundary:u,altBoundary:l,padding:c}),V=R?T?D:A:T?E:j;x[S]>w[S]&&(V=ae(V));var N=ae(V),I=[];if(i&&I.push(q[H]<=0),s&&I.push(q[V]<=0,q[N]<=0),I.every((function(e){return e}))){k=B,P=!1;break}O.set(B,I)}if(P)for(var F=function(e){var t=b.find((function(t){var n=O.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return k=t,"break"},U=h?3:1;U>0;U--){if("break"===F(U))break}t.placement!==k&&(t.modifiersData[r]._skip=!0,t.placement=k,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ue(e,t,n){return i(e,a(t,n))}var le={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=void 0===o||o,f=n.altAxis,c=void 0!==f&&f,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,h=n.tether,m=void 0===h||h,g=n.tetherOffset,y=void 0===g?0:g,b=Y(t,{boundary:p,rootBoundary:u,padding:d,altBoundary:l}),x=C(t.placement),w=_(t.placement),L=!w,P=F(x),k="x"===P?"y":"x",W=t.modifiersData.popperOffsets,B=t.rects.reference,H=t.rects.popper,T="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,R="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,q={x:0,y:0};if(W){if(s){var V,N="y"===P?j:A,I="y"===P?E:D,U="y"===P?"height":"width",z=W[P],X=z+b[N],G=z-b[I],J=m?-H[U]/2:0,K=w===M?B[U]:H[U],Q=w===M?-H[U]:-B[U],Z=t.elements.arrow,$=m&&Z?v(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[N],ne=ee[I],re=ue(0,B[U],$[U]),oe=L?B[U]/2-J-re-te-R.mainAxis:K-re-te-R.mainAxis,ie=L?-B[U]/2+J+re+ne+R.mainAxis:Q+re+ne+R.mainAxis,ae=t.elements.arrow&&O(t.elements.arrow),se=ae?"y"===P?ae.clientTop||0:ae.clientLeft||0:0,fe=null!=(V=null==S?void 0:S[P])?V:0,ce=z+ie-fe,pe=ue(m?a(X,z+oe-fe-se):X,z,m?i(G,ce):G);W[P]=pe,q[P]=pe-z}if(c){var le,de="x"===P?j:A,he="x"===P?E:D,me=W[k],ve="y"===k?"height":"width",ge=me+b[de],ye=me-b[he],be=-1!==[j,A].indexOf(x),xe=null!=(le=null==S?void 0:S[k])?le:0,we=be?ge:me-B[ve]-H[ve]-xe+R.altAxis,Oe=be?me+B[ve]+H[ve]-xe-R.altAxis:ye,je=m&&be?function(e,t,n){var r=ue(e,t,n);return r>n?n:r}(we,me,Oe):ue(m?we:ge,me,m?Oe:ye);W[k]=je,q[k]=je-me}t.modifiersData[r]=q}},requiresIfExists:["offset"]};var de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,o=e.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=C(n.placement),f=F(s),c=[A,D].indexOf(s)>=0?"height":"width";if(i&&a){var p=function(e,t){return z("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,P))}(o.padding,n),u=v(i),l="y"===f?j:A,d="y"===f?E:D,h=n.rects.reference[c]+n.rects.reference[f]-a[f]-n.rects.popper[c],m=a[f]-n.rects.reference[f],g=O(i),y=g?"y"===f?g.clientHeight||0:g.clientWidth||0:0,b=h/2-m/2,x=p[l],w=y-u[c]-p[d],L=y/2-u[c]/2+b,M=ue(x,L,w),k=f;n.modifiersData[r]=((t={})[k]=M,t.centerOffset=M-L,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&q(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function he(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function me(e){return[j,D,E,A].some((function(t){return e[t]>=0}))}var ve={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=Y(t,{elementContext:"reference"}),s=Y(t,{altBoundary:!0}),f=he(a,r),c=he(s,o,i),p=me(f),u=me(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},ge=K({defaultModifiers:[Z,$,ne,re]}),ye=[Z,$,ne,re,oe,pe,le,de,ve],be=K({defaultModifiers:ye});e.applyStyles=re,e.arrow=de,e.computeStyles=ne,e.createPopper=be,e.createPopperLite=ge,e.defaultModifiers=ye,e.detectOverflow=Y,e.eventListeners=Z,e.flip=pe,e.hide=ve,e.offset=oe,e.popperGenerator=K,e.popperOffsets=$,e.preventOverflow=le,Object.defineProperty(e,"__esModule",{value:!0})})); - - - - - - - - + + + + - + -
-
+
-
-
-

Test

-
-
+ - -
-
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeMin"
+

Test

+
-
-The minimum of the cohort sizes defined in the following rules: + +
## i Loading crmPack
+
## [1] "CohortSizeMin"
+The minimum of the cohort sizes defined in the following rules:
Defined by the dose to be used in the next cohort @@ -3064,7 +406,6 @@

Test

-
@@ -3116,248 +457,52 @@

Test

-
-
+ + + +
-
- - + + + + -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html index 04ef15ade..adbca6d62 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html @@ -1,3019 +1,361 @@ - - - + - + + + + -Test - - - - - + + + + + + + + + + - // walk the TOC and expand / collapse any items that should be shown + - if (tocEl) { - walk(tocEl, 0); - updateActiveLink(); + + - // Throttle the scroll event and walk peridiocally - window.document.addEventListener( - "scroll", - throttle(() => { - if (tocEl) { - updateActiveLink(); - walk(tocEl, 0); - } - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 5) - ); - window.addEventListener( - "resize", - throttle(() => { - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 10) - ); - hideOverlappedSidebars(); - highlightReaderToggle(isReaderMode()); -}); -// grouped tabsets -window.addEventListener("pageshow", (_event) => { - function getTabSettings() { - const data = localStorage.getItem("quarto-persistent-tabsets-data"); - if (!data) { - localStorage.setItem("quarto-persistent-tabsets-data", "{}"); - return {}; - } - if (data) { - return JSON.parse(data); - } - } - function setTabSettings(data) { - localStorage.setItem( - "quarto-persistent-tabsets-data", - JSON.stringify(data) - ); - } - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } - function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); -function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; + -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Popper={})}(this,(function(e){"use strict";function t(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function n(e){return e instanceof t(e).Element||e instanceof Element}function r(e){return e instanceof t(e).HTMLElement||e instanceof HTMLElement}function o(e){return"undefined"!=typeof ShadowRoot&&(e instanceof t(e).ShadowRoot||e instanceof ShadowRoot)}var i=Math.max,a=Math.min,s=Math.round;function f(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),o=1,i=1;if(r(e)&&t){var a=e.offsetHeight,f=e.offsetWidth;f>0&&(o=s(n.width)/f||1),a>0&&(i=s(n.height)/a||1)}return{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function c(e){var n=t(e);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function p(e){return e?(e.nodeName||"").toLowerCase():null}function u(e){return((n(e)?e.ownerDocument:e.document)||window.document).documentElement}function l(e){return f(u(e)).left+c(e).scrollLeft}function d(e){return t(e).getComputedStyle(e)}function h(e){var t=d(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function m(e,n,o){void 0===o&&(o=!1);var i,a,d=r(n),m=r(n)&&function(e){var t=e.getBoundingClientRect(),n=s(t.width)/e.offsetWidth||1,r=s(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(n),v=u(n),g=f(e,m),y={scrollLeft:0,scrollTop:0},b={x:0,y:0};return(d||!d&&!o)&&(("body"!==p(n)||h(v))&&(y=(i=n)!==t(i)&&r(i)?{scrollLeft:(a=i).scrollLeft,scrollTop:a.scrollTop}:c(i)),r(n)?((b=f(n,!0)).x+=n.clientLeft,b.y+=n.clientTop):v&&(b.x=l(v))),{x:g.left+y.scrollLeft-b.x,y:g.top+y.scrollTop-b.y,width:g.width,height:g.height}}function v(e){var t=f(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function g(e){return"html"===p(e)?e:e.assignedSlot||e.parentNode||(o(e)?e.host:null)||u(e)}function y(e){return["html","body","#document"].indexOf(p(e))>=0?e.ownerDocument.body:r(e)&&h(e)?e:y(g(e))}function b(e,n){var r;void 0===n&&(n=[]);var o=y(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=t(o),s=i?[a].concat(a.visualViewport||[],h(o)?o:[]):o,f=n.concat(s);return i?f:f.concat(b(g(s)))}function x(e){return["table","td","th"].indexOf(p(e))>=0}function w(e){return r(e)&&"fixed"!==d(e).position?e.offsetParent:null}function O(e){for(var n=t(e),i=w(e);i&&x(i)&&"static"===d(i).position;)i=w(i);return i&&("html"===p(i)||"body"===p(i)&&"static"===d(i).position)?n:i||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&r(e)&&"fixed"===d(e).position)return null;var n=g(e);for(o(n)&&(n=n.host);r(n)&&["html","body"].indexOf(p(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||n}var j="top",E="bottom",D="right",A="left",L="auto",P=[j,E,D,A],M="start",k="end",W="viewport",B="popper",H=P.reduce((function(e,t){return e.concat([t+"-"+M,t+"-"+k])}),[]),T=[].concat(P,[L]).reduce((function(e,t){return e.concat([t,t+"-"+M,t+"-"+k])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function S(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||o(e)})),r}function C(e){return e.split("-")[0]}function q(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function V(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function N(e,r){return r===W?V(function(e){var n=t(e),r=u(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;return o&&(i=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,f=o.offsetTop)),{width:i,height:a,x:s+l(e),y:f}}(e)):n(r)?function(e){var t=f(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(r):V(function(e){var t,n=u(e),r=c(e),o=null==(t=e.ownerDocument)?void 0:t.body,a=i(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=i(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+l(e),p=-r.scrollTop;return"rtl"===d(o||n).direction&&(f+=i(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:f,y:p}}(u(e)))}function I(e,t,o){var s="clippingParents"===t?function(e){var t=b(g(e)),o=["absolute","fixed"].indexOf(d(e).position)>=0&&r(e)?O(e):e;return n(o)?t.filter((function(e){return n(e)&&q(e,o)&&"body"!==p(e)})):[]}(e):[].concat(t),f=[].concat(s,[o]),c=f[0],u=f.reduce((function(t,n){var r=N(e,n);return t.top=i(r.top,t.top),t.right=a(r.right,t.right),t.bottom=a(r.bottom,t.bottom),t.left=i(r.left,t.left),t}),N(e,c));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function _(e){return e.split("-")[1]}function F(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function U(e){var t,n=e.reference,r=e.element,o=e.placement,i=o?C(o):null,a=o?_(o):null,s=n.x+n.width/2-r.width/2,f=n.y+n.height/2-r.height/2;switch(i){case j:t={x:s,y:n.y-r.height};break;case E:t={x:s,y:n.y+n.height};break;case D:t={x:n.x+n.width,y:f};break;case A:t={x:n.x-r.width,y:f};break;default:t={x:n.x,y:n.y}}var c=i?F(i):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case M:t[c]=t[c]-(n[p]/2-r[p]/2);break;case k:t[c]=t[c]+(n[p]/2-r[p]/2)}}return t}function z(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Y(e,t){void 0===t&&(t={});var r=t,o=r.placement,i=void 0===o?e.placement:o,a=r.boundary,s=void 0===a?"clippingParents":a,c=r.rootBoundary,p=void 0===c?W:c,l=r.elementContext,d=void 0===l?B:l,h=r.altBoundary,m=void 0!==h&&h,v=r.padding,g=void 0===v?0:v,y=z("number"!=typeof g?g:X(g,P)),b=d===B?"reference":B,x=e.rects.popper,w=e.elements[m?b:d],O=I(n(w)?w:w.contextElement||u(e.elements.popper),s,p),A=f(e.elements.reference),L=U({reference:A,element:x,strategy:"absolute",placement:i}),M=V(Object.assign({},x,L)),k=d===B?M:A,H={top:O.top-k.top+y.top,bottom:k.bottom-O.bottom+y.bottom,left:O.left-k.left+y.left,right:k.right-O.right+y.right},T=e.modifiersData.offset;if(d===B&&T){var R=T[i];Object.keys(H).forEach((function(e){var t=[D,E].indexOf(e)>=0?1:-1,n=[j,E].indexOf(e)>=0?"y":"x";H[e]+=R[n]*t}))}return H}var G={placement:"bottom",modifiers:[],strategy:"absolute"};function J(){for(var e=arguments.length,t=new Array(e),n=0;n=0?-1:1,i="function"==typeof n?n(Object.assign({},t,{placement:e})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[A,D].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,i),e}),{}),s=a[t.placement],f=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},ie={left:"right",right:"left",bottom:"top",top:"bottom"};function ae(e){return e.replace(/left|right|bottom|top/g,(function(e){return ie[e]}))}var se={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return se[e]}))}function ce(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=void 0===f?T:f,p=_(r),u=p?s?H:H.filter((function(e){return _(e)===p})):P,l=u.filter((function(e){return c.indexOf(e)>=0}));0===l.length&&(l=u);var d=l.reduce((function(t,n){return t[n]=Y(e,{placement:n,boundary:o,rootBoundary:i,padding:a})[C(n)],t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}var pe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0===a||a,f=n.fallbackPlacements,c=n.padding,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.flipVariations,h=void 0===d||d,m=n.allowedAutoPlacements,v=t.options.placement,g=C(v),y=f||(g===v||!h?[ae(v)]:function(e){if(C(e)===L)return[];var t=ae(e);return[fe(e),t,fe(t)]}(v)),b=[v].concat(y).reduce((function(e,n){return e.concat(C(n)===L?ce(t,{placement:n,boundary:p,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,O=new Map,P=!0,k=b[0],W=0;W=0,S=R?"width":"height",q=Y(t,{placement:B,boundary:p,rootBoundary:u,altBoundary:l,padding:c}),V=R?T?D:A:T?E:j;x[S]>w[S]&&(V=ae(V));var N=ae(V),I=[];if(i&&I.push(q[H]<=0),s&&I.push(q[V]<=0,q[N]<=0),I.every((function(e){return e}))){k=B,P=!1;break}O.set(B,I)}if(P)for(var F=function(e){var t=b.find((function(t){var n=O.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return k=t,"break"},U=h?3:1;U>0;U--){if("break"===F(U))break}t.placement!==k&&(t.modifiersData[r]._skip=!0,t.placement=k,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ue(e,t,n){return i(e,a(t,n))}var le={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=void 0===o||o,f=n.altAxis,c=void 0!==f&&f,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,h=n.tether,m=void 0===h||h,g=n.tetherOffset,y=void 0===g?0:g,b=Y(t,{boundary:p,rootBoundary:u,padding:d,altBoundary:l}),x=C(t.placement),w=_(t.placement),L=!w,P=F(x),k="x"===P?"y":"x",W=t.modifiersData.popperOffsets,B=t.rects.reference,H=t.rects.popper,T="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,R="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,q={x:0,y:0};if(W){if(s){var V,N="y"===P?j:A,I="y"===P?E:D,U="y"===P?"height":"width",z=W[P],X=z+b[N],G=z-b[I],J=m?-H[U]/2:0,K=w===M?B[U]:H[U],Q=w===M?-H[U]:-B[U],Z=t.elements.arrow,$=m&&Z?v(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[N],ne=ee[I],re=ue(0,B[U],$[U]),oe=L?B[U]/2-J-re-te-R.mainAxis:K-re-te-R.mainAxis,ie=L?-B[U]/2+J+re+ne+R.mainAxis:Q+re+ne+R.mainAxis,ae=t.elements.arrow&&O(t.elements.arrow),se=ae?"y"===P?ae.clientTop||0:ae.clientLeft||0:0,fe=null!=(V=null==S?void 0:S[P])?V:0,ce=z+ie-fe,pe=ue(m?a(X,z+oe-fe-se):X,z,m?i(G,ce):G);W[P]=pe,q[P]=pe-z}if(c){var le,de="x"===P?j:A,he="x"===P?E:D,me=W[k],ve="y"===k?"height":"width",ge=me+b[de],ye=me-b[he],be=-1!==[j,A].indexOf(x),xe=null!=(le=null==S?void 0:S[k])?le:0,we=be?ge:me-B[ve]-H[ve]-xe+R.altAxis,Oe=be?me+B[ve]+H[ve]-xe-R.altAxis:ye,je=m&&be?function(e,t,n){var r=ue(e,t,n);return r>n?n:r}(we,me,Oe):ue(m?we:ge,me,m?Oe:ye);W[k]=je,q[k]=je-me}t.modifiersData[r]=q}},requiresIfExists:["offset"]};var de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,o=e.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=C(n.placement),f=F(s),c=[A,D].indexOf(s)>=0?"height":"width";if(i&&a){var p=function(e,t){return z("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,P))}(o.padding,n),u=v(i),l="y"===f?j:A,d="y"===f?E:D,h=n.rects.reference[c]+n.rects.reference[f]-a[f]-n.rects.popper[c],m=a[f]-n.rects.reference[f],g=O(i),y=g?"y"===f?g.clientHeight||0:g.clientWidth||0:0,b=h/2-m/2,x=p[l],w=y-u[c]-p[d],L=y/2-u[c]/2+b,M=ue(x,L,w),k=f;n.modifiersData[r]=((t={})[k]=M,t.centerOffset=M-L,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&q(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function he(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function me(e){return[j,D,E,A].some((function(t){return e[t]>=0}))}var ve={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=Y(t,{elementContext:"reference"}),s=Y(t,{altBoundary:!0}),f=he(a,r),c=he(s,o,i),p=me(f),u=me(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},ge=K({defaultModifiers:[Z,$,ne,re]}),ye=[Z,$,ne,re,oe,pe,le,de,ve],be=K({defaultModifiers:ye});e.applyStyles=re,e.arrow=de,e.computeStyles=ne,e.createPopper=be,e.createPopperLite=ge,e.defaultModifiers=ye,e.detectOverflow=Y,e.eventListeners=Z,e.flip=pe,e.hide=ve,e.offset=oe,e.popperGenerator=K,e.popperOffsets=$,e.preventOverflow=le,Object.defineProperty(e,"__esModule",{value:!0})})); - - - - - - - - + + + + - + -
-
+
-
-
-

Test

-
-
+ - -
-
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeOrdinal"
+

Test

+
-
-Based on a toxicity garde of 1: + +
## i Loading crmPack
+
## [1] "CohortSizeOrdinal"
+Based on a toxicity grade of 1:
Defined by the dose to be used in the next cohort @@ -3064,248 +406,52 @@

Test

-
-
+ + + +
-
- - + + + + -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html index 7c4eceb16..adb4e99fa 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html @@ -1,3258 +1,407 @@ - - - + - + + + + -Test - - - + + + + + + + + + + - // read a meta tag value - function getMeta(metaName) { - const metas = window.document.getElementsByTagName("meta"); - for (let i = 0; i < metas.length; i++) { - if (metas[i].getAttribute("name") === metaName) { - return metas[i].getAttribute("content"); - } - } - return ""; - } + - async function findAndActivateCategories() { - const currentPagePath = offsetAbsoluteUrl(window.location.href); - const response = await fetch(offsetRelativeUrl("listings.json")); - if (response.status == 200) { - return response.json().then(function (listingPaths) { - const listingHrefs = []; - for (const listingPath of listingPaths) { - const pathWithoutLeadingSlash = listingPath.listing.substring(1); - for (const item of listingPath.items) { - if ( - item === currentPagePath || - item === currentPagePath + "index.html" - ) { - // Resolve this path against the offset to be sure - // we already are using the correct path to the listing - // (this adjusts the listing urls to be rooted against - // whatever root the page is actually running against) - const relative = offsetRelativeUrl(pathWithoutLeadingSlash); - const baseUrl = window.location; - const resolvedPath = new URL(relative, baseUrl); - listingHrefs.push(resolvedPath.pathname); - break; - } - } - } - - // Look up the tree for a nearby linting and use that if we find one - const nearestListing = findNearestParentListing( - offsetAbsoluteUrl(window.location.pathname), - listingHrefs - ); - if (nearestListing) { - activateCategories(nearestListing); - } else { - // See if the referrer is a listing page for this item - const referredRelativePath = offsetAbsoluteUrl(document.referrer); - const referrerListing = listingHrefs.find((listingHref) => { - const isListingReferrer = - listingHref === referredRelativePath || - listingHref === referredRelativePath + "index.html"; - return isListingReferrer; - }); - - if (referrerListing) { - // Try to use the referrer if possible - activateCategories(referrerListing); - } else if (listingHrefs.length > 0) { - // Otherwise, just fall back to the first listing - activateCategories(listingHrefs[0]); - } - } - }); - } - } - if (hasTitleCategories()) { - findAndActivateCategories(); + + - const findNearestParentListing = (href, listingHrefs) => { - if (!href || !listingHrefs) { - return undefined; - } - // Look up the tree for a nearby linting and use that if we find one - const relativeParts = href.substring(1).split("/"); - while (relativeParts.length > 0) { - const path = relativeParts.join("/"); - for (const listingHref of listingHrefs) { - if (listingHref.startsWith(path)) { - return listingHref; - } - } - relativeParts.pop(); - } - return undefined; - }; - const manageSidebarVisiblity = (el, placeholderDescriptor) => { - let isVisible = true; - let elRect; - return (hiddenRegions) => { - if (el === null) { - return; - } - // Find the last element of the TOC - const lastChildEl = el.lastElementChild; - if (lastChildEl) { - // Converts the sidebar to a menu - const convertToMenu = () => { - for (const child of el.children) { - child.style.opacity = 0; - child.style.overflow = "hidden"; - } - nexttick(() => { - const toggleContainer = window.document.createElement("div"); - toggleContainer.style.width = "100%"; - toggleContainer.classList.add("zindex-over-content"); - toggleContainer.classList.add("quarto-sidebar-toggle"); - toggleContainer.classList.add("headroom-target"); // Marks this to be managed by headeroom - toggleContainer.id = placeholderDescriptor.id; - toggleContainer.style.position = "fixed"; - - const toggleIcon = window.document.createElement("i"); - toggleIcon.classList.add("quarto-sidebar-toggle-icon"); - toggleIcon.classList.add("bi"); - toggleIcon.classList.add("bi-caret-down-fill"); - - const toggleTitle = window.document.createElement("div"); - const titleEl = window.document.body.querySelector( - placeholderDescriptor.titleSelector - ); - if (titleEl) { - toggleTitle.append( - titleEl.textContent || titleEl.innerText, - toggleIcon - ); - } - toggleTitle.classList.add("zindex-over-content"); - toggleTitle.classList.add("quarto-sidebar-toggle-title"); - toggleContainer.append(toggleTitle); - - const toggleContents = window.document.createElement("div"); - toggleContents.classList = el.classList; - toggleContents.classList.add("zindex-over-content"); - toggleContents.classList.add("quarto-sidebar-toggle-contents"); - for (const child of el.children) { - if (child.id === "toc-title") { - continue; - } - - const clone = child.cloneNode(true); - clone.style.opacity = 1; - clone.style.display = null; - toggleContents.append(clone); - } - toggleContents.style.height = "0px"; - const positionToggle = () => { - // position the element (top left of parent, same width as parent) - if (!elRect) { - elRect = el.getBoundingClientRect(); - } - toggleContainer.style.left = `${elRect.left}px`; - toggleContainer.style.top = `${elRect.top}px`; - toggleContainer.style.width = `${elRect.width}px`; - }; - positionToggle(); - - toggleContainer.append(toggleContents); - el.parentElement.prepend(toggleContainer); - - // Process clicks - let tocShowing = false; - // Allow the caller to control whether this is dismissed - // when it is clicked (e.g. sidebar navigation supports - // opening and closing the nav tree, so don't dismiss on click) - const clickEl = placeholderDescriptor.dismissOnClick - ? toggleContainer - : toggleTitle; - - const closeToggle = () => { - if (tocShowing) { - toggleContainer.classList.remove("expanded"); - toggleContents.style.height = "0px"; - tocShowing = false; - } - }; - - // Get rid of any expanded toggle if the user scrolls - window.document.addEventListener( - "scroll", - throttle(() => { - closeToggle(); - }, 50) - ); - - // Handle positioning of the toggle - window.addEventListener( - "resize", - throttle(() => { - elRect = undefined; - positionToggle(); - }, 50) - ); - - window.addEventListener("quarto-hrChanged", () => { - elRect = undefined; - }); - - // Process the click - clickEl.onclick = () => { - if (!tocShowing) { - toggleContainer.classList.add("expanded"); - toggleContents.style.height = null; - tocShowing = true; - } else { - closeToggle(); - } - }; - }); - }; - - // Converts a sidebar from a menu back to a sidebar - const convertToSidebar = () => { - for (const child of el.children) { - child.style.opacity = 1; - child.style.overflow = null; - } - const placeholderEl = window.document.getElementById( - placeholderDescriptor.id - ); - if (placeholderEl) { - placeholderEl.remove(); - } - el.classList.remove("rollup"); - }; - - if (isReaderMode()) { - convertToMenu(); - isVisible = false; - } else { - // Find the top and bottom o the element that is being managed - const elTop = el.offsetTop; - const elBottom = - elTop + lastChildEl.offsetTop + lastChildEl.offsetHeight; - - if (!isVisible) { - // If the element is current not visible reveal if there are - // no conflicts with overlay regions - if (!inHiddenRegion(elTop, elBottom, hiddenRegions)) { - convertToSidebar(); - isVisible = true; - } - } else { - // If the element is visible, hide it if it conflicts with overlay regions - // and insert a placeholder toggle (or if we're in reader mode) - if (inHiddenRegion(elTop, elBottom, hiddenRegions)) { - convertToMenu(); - isVisible = false; - } - } - } - } - }; - }; + - const tabEls = document.querySelectorAll('a[data-bs-toggle="tab"]'); - for (const tabEl of tabEls) { - const id = tabEl.getAttribute("data-bs-target"); - if (id) { - const columnEl = document.querySelector( - `${id} .column-margin, .tabset-margin-content` - ); - if (columnEl) - tabEl.addEventListener("shown.bs.tab", function (event) { - const el = event.srcElement; - if (el) { - const visibleCls = `${el.id}-margin-content`; - // walk up until we find a parent tabset - let panelTabsetEl = el.parentElement; - while (panelTabsetEl) { - if (panelTabsetEl.classList.contains("panel-tabset")) { - break; - } - panelTabsetEl = panelTabsetEl.parentElement; - } - - if (panelTabsetEl) { - const prevSib = panelTabsetEl.previousElementSibling; - if ( - prevSib && - prevSib.classList.contains("tabset-margin-container") - ) { - const childNodes = prevSib.querySelectorAll( - ".tabset-margin-content" - ); - for (const childEl of childNodes) { - if (childEl.classList.contains(visibleCls)) { - childEl.classList.remove("collapse"); - } else { - childEl.classList.add("collapse"); - } - } - } - } - } - layoutMarginEls(); - }); - } - } - // Manage the visibility of the toc and the sidebar - const marginScrollVisibility = manageSidebarVisiblity(marginSidebarEl, { - id: "quarto-toc-toggle", - titleSelector: "#toc-title", - dismissOnClick: true, - }); - const sidebarScrollVisiblity = manageSidebarVisiblity(sidebarEl, { - id: "quarto-sidebarnav-toggle", - titleSelector: ".title", - dismissOnClick: false, - }); - let tocLeftScrollVisibility; - if (leftTocEl) { - tocLeftScrollVisibility = manageSidebarVisiblity(leftTocEl, { - id: "quarto-lefttoc-toggle", - titleSelector: "#toc-title", - dismissOnClick: true, - }); - } - - // Find the first element that uses formatting in special columns - const conflictingEls = window.document.body.querySelectorAll( - '[class^="column-"], [class*=" column-"], aside, [class*="margin-caption"], [class*=" margin-caption"], [class*="margin-ref"], [class*=" margin-ref"]' - ); - - // Filter all the possibly conflicting elements into ones - // the do conflict on the left or ride side - const arrConflictingEls = Array.from(conflictingEls); - const leftSideConflictEls = arrConflictingEls.filter((el) => { - if (el.tagName === "ASIDE") { - return false; - } - return Array.from(el.classList).find((className) => { - return ( - className !== "column-body" && - className.startsWith("column-") && - !className.endsWith("right") && - !className.endsWith("container") && - className !== "column-margin" - ); - }); - }); - const rightSideConflictEls = arrConflictingEls.filter((el) => { - if (el.tagName === "ASIDE") { - return true; - } + - const hasMarginCaption = Array.from(el.classList).find((className) => { - return className == "margin-caption"; - }); - if (hasMarginCaption) { - return true; - } - - return Array.from(el.classList).find((className) => { - return ( - className !== "column-body" && - !className.endsWith("container") && - className.startsWith("column-") && - !className.endsWith("left") - ); - }); - }); + - const kOverlapPaddingSize = 10; - function toRegions(els) { - return els.map((el) => { - const boundRect = el.getBoundingClientRect(); - const top = - boundRect.top + - document.documentElement.scrollTop - - kOverlapPaddingSize; - return { - top, - bottom: top + el.scrollHeight + 2 * kOverlapPaddingSize, - }; - }); - } + - let hasObserved = false; - const visibleItemObserver = (els) => { - let visibleElements = [...els]; - const intersectionObserver = new IntersectionObserver( - (entries, _observer) => { - entries.forEach((entry) => { - if (entry.isIntersecting) { - if (visibleElements.indexOf(entry.target) === -1) { - visibleElements.push(entry.target); - } - } else { - visibleElements = visibleElements.filter((visibleEntry) => { - return visibleEntry !== entry; - }); - } - }); - if (!hasObserved) { - hideOverlappedSidebars(); - } - hasObserved = true; - }, - {} - ); - els.forEach((el) => { - intersectionObserver.observe(el); - }); - return { - getVisibleEntries: () => { - return visibleElements; - }, - }; - }; - const rightElementObserver = visibleItemObserver(rightSideConflictEls); - const leftElementObserver = visibleItemObserver(leftSideConflictEls); - - const hideOverlappedSidebars = () => { - marginScrollVisibility(toRegions(rightElementObserver.getVisibleEntries())); - sidebarScrollVisiblity(toRegions(leftElementObserver.getVisibleEntries())); - if (tocLeftScrollVisibility) { - tocLeftScrollVisibility( - toRegions(leftElementObserver.getVisibleEntries()) - ); - } - }; + - window.quartoToggleReader = () => { - // Applies a slow class (or removes it) - // to update the transition speed - const slowTransition = (slow) => { - const manageTransition = (id, slow) => { - const el = document.getElementById(id); - if (el) { - if (slow) { - el.classList.add("slow"); - } else { - el.classList.remove("slow"); - } - } - }; + - manageTransition("TOC", slow); - manageTransition("quarto-sidebar", slow); - }; - const readerMode = !isReaderMode(); - setReaderModeValue(readerMode); - - // If we're entering reader mode, slow the transition - if (readerMode) { - slowTransition(readerMode); - } - highlightReaderToggle(readerMode); - hideOverlappedSidebars(); - - // If we're exiting reader mode, restore the non-slow transition - if (!readerMode) { - slowTransition(!readerMode); - } - }; - const highlightReaderToggle = (readerMode) => { - const els = document.querySelectorAll(".quarto-reader-toggle"); - if (els) { - els.forEach((el) => { - if (readerMode) { - el.classList.add("reader"); - } else { - el.classList.remove("reader"); - } - }); - } - }; +
- const setReaderModeValue = (val) => { - if (window.location.protocol !== "file:") { - window.localStorage.setItem("quarto-reader-mode", val); - } else { - localReaderMode = val; - } - }; - const isReaderMode = () => { - if (window.location.protocol !== "file:") { - return window.localStorage.getItem("quarto-reader-mode") === "true"; - } else { - return localReaderMode; - } - }; - let localReaderMode = null; - - const tocOpenDepthStr = tocEl?.getAttribute("data-toc-expanded"); - const tocOpenDepth = tocOpenDepthStr ? Number(tocOpenDepthStr) : 1; - - // Walk the TOC and collapse/expand nodes - // Nodes are expanded if: - // - they are top level - // - they have children that are 'active' links - // - they are directly below an link that is 'active' - const walk = (el, depth) => { - // Tick depth when we enter a UL - if (el.tagName === "UL") { - depth = depth + 1; - } - - // It this is active link - let isActiveNode = false; - if (el.tagName === "A" && el.classList.contains("active")) { - isActiveNode = true; - } - - // See if there is an active child to this element - let hasActiveChild = false; - for (child of el.children) { - hasActiveChild = walk(child, depth) || hasActiveChild; - } - - // Process the collapse state if this is an UL - if (el.tagName === "UL") { - if (tocOpenDepth === -1 && depth > 1) { - el.classList.add("collapse"); - } else if ( - depth <= tocOpenDepth || - hasActiveChild || - prevSiblingIsActiveLink(el) - ) { - el.classList.remove("collapse"); - } else { - el.classList.add("collapse"); - } - // untick depth when we leave a UL - depth = depth - 1; - } - return hasActiveChild || isActiveNode; - }; - // walk the TOC and expand / collapse any items that should be shown + - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } +
## i Loading crmPack
+
## [1] "CohortSizeParts"
+

A size of 1 participant in the first part and 3 participants in the +second.

- function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); +
-function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; -} + - - - - - - - - - - - - - - -
- -
-
-
-

Test

-
- - - -
+ - - - -
- - -
- -
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeParts"
-
-
-

A size of 1 participant in the first part and 3 participants in the second.

-
-
+ -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html index 0bba5c584..0917d5823 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html @@ -1,3290 +1,456 @@ - - - + - + + + + -Test - - - - - + + + + + + + + + + - // walk the TOC and expand / collapse any items that should be shown + - if (tocEl) { - walk(tocEl, 0); - updateActiveLink(); + + - // Throttle the scroll event and walk peridiocally - window.document.addEventListener( - "scroll", - throttle(() => { - if (tocEl) { - updateActiveLink(); - walk(tocEl, 0); - } - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 5) - ); - window.addEventListener( - "resize", - throttle(() => { - if (!isReaderMode()) { - hideOverlappedSidebars(); - } - }, 10) - ); - hideOverlappedSidebars(); - highlightReaderToggle(isReaderMode()); -}); -// grouped tabsets -window.addEventListener("pageshow", (_event) => { - function getTabSettings() { - const data = localStorage.getItem("quarto-persistent-tabsets-data"); - if (!data) { - localStorage.setItem("quarto-persistent-tabsets-data", "{}"); - return {}; - } - if (data) { - return JSON.parse(data); - } - } - function setTabSettings(data) { - localStorage.setItem( - "quarto-persistent-tabsets-data", - JSON.stringify(data) - ); - } - function setTabState(groupName, groupValue) { - const data = getTabSettings(); - data[groupName] = groupValue; - setTabSettings(data); - } - function toggleTab(tab, active) { - const tabPanelId = tab.getAttribute("aria-controls"); - const tabPanel = document.getElementById(tabPanelId); - if (active) { - tab.classList.add("active"); - tabPanel.classList.add("active"); - } else { - tab.classList.remove("active"); - tabPanel.classList.remove("active"); - } - } - function toggleAll(selectedGroup, selectorsToSync) { - for (const [thisGroup, tabs] of Object.entries(selectorsToSync)) { - const active = selectedGroup === thisGroup; - for (const tab of tabs) { - toggleTab(tab, active); - } - } - } - function findSelectorsToSyncByLanguage() { - const result = {}; - const tabs = Array.from( - document.querySelectorAll(`div[data-group] a[id^='tabset-']`) - ); - for (const item of tabs) { - const div = item.parentElement.parentElement.parentElement; - const group = div.getAttribute("data-group"); - if (!result[group]) { - result[group] = {}; - } - const selectorsToSync = result[group]; - const value = item.innerHTML; - if (!selectorsToSync[value]) { - selectorsToSync[value] = []; - } - selectorsToSync[value].push(item); - } - return result; - } - - function setupSelectorSync() { - const selectorsToSync = findSelectorsToSyncByLanguage(); - Object.entries(selectorsToSync).forEach(([group, tabSetsByValue]) => { - Object.entries(tabSetsByValue).forEach(([value, items]) => { - items.forEach((item) => { - item.addEventListener("click", (_event) => { - setTabState(group, value); - toggleAll(value, selectorsToSync[group]); - }); - }); - }); - }); - return selectorsToSync; - } - const selectorsToSync = setupSelectorSync(); - for (const [group, selectedName] of Object.entries(getTabSettings())) { - const selectors = selectorsToSync[group]; - // it's possible that stale state gives us empty selections, so we explicitly check here. - if (selectors) { - toggleAll(selectedName, selectors); - } - } -}); -function throttle(func, wait) { - let waiting = false; - return function () { - if (!waiting) { - func.apply(this, arguments); - waiting = true; - setTimeout(function () { - waiting = false; - }, wait); - } - }; + -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Popper={})}(this,(function(e){"use strict";function t(e){if(null==e)return window;if("[object Window]"!==e.toString()){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function n(e){return e instanceof t(e).Element||e instanceof Element}function r(e){return e instanceof t(e).HTMLElement||e instanceof HTMLElement}function o(e){return"undefined"!=typeof ShadowRoot&&(e instanceof t(e).ShadowRoot||e instanceof ShadowRoot)}var i=Math.max,a=Math.min,s=Math.round;function f(e,t){void 0===t&&(t=!1);var n=e.getBoundingClientRect(),o=1,i=1;if(r(e)&&t){var a=e.offsetHeight,f=e.offsetWidth;f>0&&(o=s(n.width)/f||1),a>0&&(i=s(n.height)/a||1)}return{width:n.width/o,height:n.height/i,top:n.top/i,right:n.right/o,bottom:n.bottom/i,left:n.left/o,x:n.left/o,y:n.top/i}}function c(e){var n=t(e);return{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function p(e){return e?(e.nodeName||"").toLowerCase():null}function u(e){return((n(e)?e.ownerDocument:e.document)||window.document).documentElement}function l(e){return f(u(e)).left+c(e).scrollLeft}function d(e){return t(e).getComputedStyle(e)}function h(e){var t=d(e),n=t.overflow,r=t.overflowX,o=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function m(e,n,o){void 0===o&&(o=!1);var i,a,d=r(n),m=r(n)&&function(e){var t=e.getBoundingClientRect(),n=s(t.width)/e.offsetWidth||1,r=s(t.height)/e.offsetHeight||1;return 1!==n||1!==r}(n),v=u(n),g=f(e,m),y={scrollLeft:0,scrollTop:0},b={x:0,y:0};return(d||!d&&!o)&&(("body"!==p(n)||h(v))&&(y=(i=n)!==t(i)&&r(i)?{scrollLeft:(a=i).scrollLeft,scrollTop:a.scrollTop}:c(i)),r(n)?((b=f(n,!0)).x+=n.clientLeft,b.y+=n.clientTop):v&&(b.x=l(v))),{x:g.left+y.scrollLeft-b.x,y:g.top+y.scrollTop-b.y,width:g.width,height:g.height}}function v(e){var t=f(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function g(e){return"html"===p(e)?e:e.assignedSlot||e.parentNode||(o(e)?e.host:null)||u(e)}function y(e){return["html","body","#document"].indexOf(p(e))>=0?e.ownerDocument.body:r(e)&&h(e)?e:y(g(e))}function b(e,n){var r;void 0===n&&(n=[]);var o=y(e),i=o===(null==(r=e.ownerDocument)?void 0:r.body),a=t(o),s=i?[a].concat(a.visualViewport||[],h(o)?o:[]):o,f=n.concat(s);return i?f:f.concat(b(g(s)))}function x(e){return["table","td","th"].indexOf(p(e))>=0}function w(e){return r(e)&&"fixed"!==d(e).position?e.offsetParent:null}function O(e){for(var n=t(e),i=w(e);i&&x(i)&&"static"===d(i).position;)i=w(i);return i&&("html"===p(i)||"body"===p(i)&&"static"===d(i).position)?n:i||function(e){var t=-1!==navigator.userAgent.toLowerCase().indexOf("firefox");if(-1!==navigator.userAgent.indexOf("Trident")&&r(e)&&"fixed"===d(e).position)return null;var n=g(e);for(o(n)&&(n=n.host);r(n)&&["html","body"].indexOf(p(n))<0;){var i=d(n);if("none"!==i.transform||"none"!==i.perspective||"paint"===i.contain||-1!==["transform","perspective"].indexOf(i.willChange)||t&&"filter"===i.willChange||t&&i.filter&&"none"!==i.filter)return n;n=n.parentNode}return null}(e)||n}var j="top",E="bottom",D="right",A="left",L="auto",P=[j,E,D,A],M="start",k="end",W="viewport",B="popper",H=P.reduce((function(e,t){return e.concat([t+"-"+M,t+"-"+k])}),[]),T=[].concat(P,[L]).reduce((function(e,t){return e.concat([t,t+"-"+M,t+"-"+k])}),[]),R=["beforeRead","read","afterRead","beforeMain","main","afterMain","beforeWrite","write","afterWrite"];function S(e){var t=new Map,n=new Set,r=[];function o(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach((function(e){if(!n.has(e)){var r=t.get(e);r&&o(r)}})),r.push(e)}return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||o(e)})),r}function C(e){return e.split("-")[0]}function q(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function V(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function N(e,r){return r===W?V(function(e){var n=t(e),r=u(e),o=n.visualViewport,i=r.clientWidth,a=r.clientHeight,s=0,f=0;return o&&(i=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(s=o.offsetLeft,f=o.offsetTop)),{width:i,height:a,x:s+l(e),y:f}}(e)):n(r)?function(e){var t=f(e);return t.top=t.top+e.clientTop,t.left=t.left+e.clientLeft,t.bottom=t.top+e.clientHeight,t.right=t.left+e.clientWidth,t.width=e.clientWidth,t.height=e.clientHeight,t.x=t.left,t.y=t.top,t}(r):V(function(e){var t,n=u(e),r=c(e),o=null==(t=e.ownerDocument)?void 0:t.body,a=i(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),s=i(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),f=-r.scrollLeft+l(e),p=-r.scrollTop;return"rtl"===d(o||n).direction&&(f+=i(n.clientWidth,o?o.clientWidth:0)-a),{width:a,height:s,x:f,y:p}}(u(e)))}function I(e,t,o){var s="clippingParents"===t?function(e){var t=b(g(e)),o=["absolute","fixed"].indexOf(d(e).position)>=0&&r(e)?O(e):e;return n(o)?t.filter((function(e){return n(e)&&q(e,o)&&"body"!==p(e)})):[]}(e):[].concat(t),f=[].concat(s,[o]),c=f[0],u=f.reduce((function(t,n){var r=N(e,n);return t.top=i(r.top,t.top),t.right=a(r.right,t.right),t.bottom=a(r.bottom,t.bottom),t.left=i(r.left,t.left),t}),N(e,c));return u.width=u.right-u.left,u.height=u.bottom-u.top,u.x=u.left,u.y=u.top,u}function _(e){return e.split("-")[1]}function F(e){return["top","bottom"].indexOf(e)>=0?"x":"y"}function U(e){var t,n=e.reference,r=e.element,o=e.placement,i=o?C(o):null,a=o?_(o):null,s=n.x+n.width/2-r.width/2,f=n.y+n.height/2-r.height/2;switch(i){case j:t={x:s,y:n.y-r.height};break;case E:t={x:s,y:n.y+n.height};break;case D:t={x:n.x+n.width,y:f};break;case A:t={x:n.x-r.width,y:f};break;default:t={x:n.x,y:n.y}}var c=i?F(i):null;if(null!=c){var p="y"===c?"height":"width";switch(a){case M:t[c]=t[c]-(n[p]/2-r[p]/2);break;case k:t[c]=t[c]+(n[p]/2-r[p]/2)}}return t}function z(e){return Object.assign({},{top:0,right:0,bottom:0,left:0},e)}function X(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function Y(e,t){void 0===t&&(t={});var r=t,o=r.placement,i=void 0===o?e.placement:o,a=r.boundary,s=void 0===a?"clippingParents":a,c=r.rootBoundary,p=void 0===c?W:c,l=r.elementContext,d=void 0===l?B:l,h=r.altBoundary,m=void 0!==h&&h,v=r.padding,g=void 0===v?0:v,y=z("number"!=typeof g?g:X(g,P)),b=d===B?"reference":B,x=e.rects.popper,w=e.elements[m?b:d],O=I(n(w)?w:w.contextElement||u(e.elements.popper),s,p),A=f(e.elements.reference),L=U({reference:A,element:x,strategy:"absolute",placement:i}),M=V(Object.assign({},x,L)),k=d===B?M:A,H={top:O.top-k.top+y.top,bottom:k.bottom-O.bottom+y.bottom,left:O.left-k.left+y.left,right:k.right-O.right+y.right},T=e.modifiersData.offset;if(d===B&&T){var R=T[i];Object.keys(H).forEach((function(e){var t=[D,E].indexOf(e)>=0?1:-1,n=[j,E].indexOf(e)>=0?"y":"x";H[e]+=R[n]*t}))}return H}var G={placement:"bottom",modifiers:[],strategy:"absolute"};function J(){for(var e=arguments.length,t=new Array(e),n=0;n=0?-1:1,i="function"==typeof n?n(Object.assign({},t,{placement:e})):n,a=i[0],s=i[1];return a=a||0,s=(s||0)*o,[A,D].indexOf(r)>=0?{x:s,y:a}:{x:a,y:s}}(n,t.rects,i),e}),{}),s=a[t.placement],f=s.x,c=s.y;null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=f,t.modifiersData.popperOffsets.y+=c),t.modifiersData[r]=a}},ie={left:"right",right:"left",bottom:"top",top:"bottom"};function ae(e){return e.replace(/left|right|bottom|top/g,(function(e){return ie[e]}))}var se={start:"end",end:"start"};function fe(e){return e.replace(/start|end/g,(function(e){return se[e]}))}function ce(e,t){void 0===t&&(t={});var n=t,r=n.placement,o=n.boundary,i=n.rootBoundary,a=n.padding,s=n.flipVariations,f=n.allowedAutoPlacements,c=void 0===f?T:f,p=_(r),u=p?s?H:H.filter((function(e){return _(e)===p})):P,l=u.filter((function(e){return c.indexOf(e)>=0}));0===l.length&&(l=u);var d=l.reduce((function(t,n){return t[n]=Y(e,{placement:n,boundary:o,rootBoundary:i,padding:a})[C(n)],t}),{});return Object.keys(d).sort((function(e,t){return d[e]-d[t]}))}var pe={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var o=n.mainAxis,i=void 0===o||o,a=n.altAxis,s=void 0===a||a,f=n.fallbackPlacements,c=n.padding,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.flipVariations,h=void 0===d||d,m=n.allowedAutoPlacements,v=t.options.placement,g=C(v),y=f||(g===v||!h?[ae(v)]:function(e){if(C(e)===L)return[];var t=ae(e);return[fe(e),t,fe(t)]}(v)),b=[v].concat(y).reduce((function(e,n){return e.concat(C(n)===L?ce(t,{placement:n,boundary:p,rootBoundary:u,padding:c,flipVariations:h,allowedAutoPlacements:m}):n)}),[]),x=t.rects.reference,w=t.rects.popper,O=new Map,P=!0,k=b[0],W=0;W=0,S=R?"width":"height",q=Y(t,{placement:B,boundary:p,rootBoundary:u,altBoundary:l,padding:c}),V=R?T?D:A:T?E:j;x[S]>w[S]&&(V=ae(V));var N=ae(V),I=[];if(i&&I.push(q[H]<=0),s&&I.push(q[V]<=0,q[N]<=0),I.every((function(e){return e}))){k=B,P=!1;break}O.set(B,I)}if(P)for(var F=function(e){var t=b.find((function(t){var n=O.get(t);if(n)return n.slice(0,e).every((function(e){return e}))}));if(t)return k=t,"break"},U=h?3:1;U>0;U--){if("break"===F(U))break}t.placement!==k&&(t.modifiersData[r]._skip=!0,t.placement=k,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}};function ue(e,t,n){return i(e,a(t,n))}var le={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options,r=e.name,o=n.mainAxis,s=void 0===o||o,f=n.altAxis,c=void 0!==f&&f,p=n.boundary,u=n.rootBoundary,l=n.altBoundary,d=n.padding,h=n.tether,m=void 0===h||h,g=n.tetherOffset,y=void 0===g?0:g,b=Y(t,{boundary:p,rootBoundary:u,padding:d,altBoundary:l}),x=C(t.placement),w=_(t.placement),L=!w,P=F(x),k="x"===P?"y":"x",W=t.modifiersData.popperOffsets,B=t.rects.reference,H=t.rects.popper,T="function"==typeof y?y(Object.assign({},t.rects,{placement:t.placement})):y,R="number"==typeof T?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),S=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,q={x:0,y:0};if(W){if(s){var V,N="y"===P?j:A,I="y"===P?E:D,U="y"===P?"height":"width",z=W[P],X=z+b[N],G=z-b[I],J=m?-H[U]/2:0,K=w===M?B[U]:H[U],Q=w===M?-H[U]:-B[U],Z=t.elements.arrow,$=m&&Z?v(Z):{width:0,height:0},ee=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0},te=ee[N],ne=ee[I],re=ue(0,B[U],$[U]),oe=L?B[U]/2-J-re-te-R.mainAxis:K-re-te-R.mainAxis,ie=L?-B[U]/2+J+re+ne+R.mainAxis:Q+re+ne+R.mainAxis,ae=t.elements.arrow&&O(t.elements.arrow),se=ae?"y"===P?ae.clientTop||0:ae.clientLeft||0:0,fe=null!=(V=null==S?void 0:S[P])?V:0,ce=z+ie-fe,pe=ue(m?a(X,z+oe-fe-se):X,z,m?i(G,ce):G);W[P]=pe,q[P]=pe-z}if(c){var le,de="x"===P?j:A,he="x"===P?E:D,me=W[k],ve="y"===k?"height":"width",ge=me+b[de],ye=me-b[he],be=-1!==[j,A].indexOf(x),xe=null!=(le=null==S?void 0:S[k])?le:0,we=be?ge:me-B[ve]-H[ve]-xe+R.altAxis,Oe=be?me+B[ve]+H[ve]-xe-R.altAxis:ye,je=m&&be?function(e,t,n){var r=ue(e,t,n);return r>n?n:r}(we,me,Oe):ue(m?we:ge,me,m?Oe:ye);W[k]=je,q[k]=je-me}t.modifiersData[r]=q}},requiresIfExists:["offset"]};var de={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state,r=e.name,o=e.options,i=n.elements.arrow,a=n.modifiersData.popperOffsets,s=C(n.placement),f=F(s),c=[A,D].indexOf(s)>=0?"height":"width";if(i&&a){var p=function(e,t){return z("number"!=typeof(e="function"==typeof e?e(Object.assign({},t.rects,{placement:t.placement})):e)?e:X(e,P))}(o.padding,n),u=v(i),l="y"===f?j:A,d="y"===f?E:D,h=n.rects.reference[c]+n.rects.reference[f]-a[f]-n.rects.popper[c],m=a[f]-n.rects.reference[f],g=O(i),y=g?"y"===f?g.clientHeight||0:g.clientWidth||0:0,b=h/2-m/2,x=p[l],w=y-u[c]-p[d],L=y/2-u[c]/2+b,M=ue(x,L,w),k=f;n.modifiersData[r]=((t={})[k]=M,t.centerOffset=M-L,t)}},effect:function(e){var t=e.state,n=e.options.element,r=void 0===n?"[data-popper-arrow]":n;null!=r&&("string"!=typeof r||(r=t.elements.popper.querySelector(r)))&&q(t.elements.popper,r)&&(t.elements.arrow=r)},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function he(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function me(e){return[j,D,E,A].some((function(t){return e[t]>=0}))}var ve={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state,n=e.name,r=t.rects.reference,o=t.rects.popper,i=t.modifiersData.preventOverflow,a=Y(t,{elementContext:"reference"}),s=Y(t,{altBoundary:!0}),f=he(a,r),c=he(s,o,i),p=me(f),u=me(c);t.modifiersData[n]={referenceClippingOffsets:f,popperEscapeOffsets:c,isReferenceHidden:p,hasPopperEscaped:u},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":p,"data-popper-escaped":u})}},ge=K({defaultModifiers:[Z,$,ne,re]}),ye=[Z,$,ne,re,oe,pe,le,de,ve],be=K({defaultModifiers:ye});e.applyStyles=re,e.arrow=de,e.computeStyles=ne,e.createPopper=be,e.createPopperLite=ge,e.defaultModifiers=ye,e.detectOverflow=Y,e.eventListeners=Z,e.flip=pe,e.hide=ve,e.offset=oe,e.popperGenerator=K,e.popperOffsets=$,e.preventOverflow=le,Object.defineProperty(e,"__esModule",{value:!0})})); - - - - - - - - + + + + - + -
-
+
-
-
-

Test

-
-
+ - -
-
-
-
ℹ Loading crmPack
-
-
-
[1] "CohortSizeRange"
+

Test

+
-
- - ----- + + +
## i Loading crmPack
+
## [1] "CohortSizeRange"
+
Defined by the dose to be used in the next cohort
+ - - + - + + + - - - - + + + + - - - - + + + + - - - - + + + +
+Defined by the dose to be used in the next cohort +
+
+
Dose -
+
LowerUpperCohort size
+Lower + +Upper + +Cohort size +
0301
+0 + +30 + +1 +
30Inf3
+30 + +Inf + +3 +
-
+ + + +
-
- - + + + + -
+ + + + - \ No newline at end of file + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeConst.html b/tests/testthat/fixtures/knit_print_CohortSizeConst.html new file mode 100644 index 000000000..7f5ae1ce7 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeConst.html @@ -0,0 +1,406 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeConst"
+

A constant size of 3 participants.

+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeDLT.html b/tests/testthat/fixtures/knit_print_CohortSizeDLT.html new file mode 100644 index 000000000..f1bae7849 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeDLT.html @@ -0,0 +1,456 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeDLT"
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the number of DLTs so far observed +
+
+No of DLTs +
+
+
+Lower + +Upper + +Cohort size +
+0 + +1 + +1 +
+1 + +Inf + +3 +
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMax.html b/tests/testthat/fixtures/knit_print_CohortSizeMax.html new file mode 100644 index 000000000..f74cef1e0 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeMax.html @@ -0,0 +1,508 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeMax"
+The maximum of the cohort sizes defined in the following rules: + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +10 + +1 +
+10 + +Inf + +3 +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the number of DLTs so far observed +
+
+No of DLTs +
+
+
+Lower + +Upper + +Cohort size +
+0 + +1 + +1 +
+1 + +Inf + +3 +
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMin.html b/tests/testthat/fixtures/knit_print_CohortSizeMin.html new file mode 100644 index 000000000..fe4dfe8ee --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeMin.html @@ -0,0 +1,508 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeMin"
+The minimum of the cohort sizes defined in the following rules: + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +10 + +1 +
+10 + +Inf + +3 +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the number of DLTs so far observed +
+
+No of DLTs +
+
+
+Lower + +Upper + +Cohort size +
+0 + +1 + +1 +
+1 + +Inf + +3 +
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html b/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html new file mode 100644 index 000000000..adbca6d62 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html @@ -0,0 +1,457 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeOrdinal"
+Based on a toxicity grade of 1: + + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +30 + +1 +
+30 + +Inf + +3 +
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeParts.html b/tests/testthat/fixtures/knit_print_CohortSizeParts.html new file mode 100644 index 000000000..adb4e99fa --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeParts.html @@ -0,0 +1,407 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeParts"
+

A size of 1 participant in the first part and 3 participants in the +second.

+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_CohortSizeRange.html b/tests/testthat/fixtures/knit_print_CohortSizeRange.html new file mode 100644 index 000000000..0917d5823 --- /dev/null +++ b/tests/testthat/fixtures/knit_print_CohortSizeRange.html @@ -0,0 +1,456 @@ + + + + + + + + + + + + + +Test + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
## i Loading crmPack
+
## [1] "CohortSizeRange"
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+Defined by the dose to be used in the next cohort +
+
+Dose +
+
+
+Lower + +Upper + +Cohort size +
+0 + +30 + +1 +
+30 + +Inf + +3 +
+ + + + +
+ + + + + + + + + + + + + + + diff --git a/tests/testthat/fixtures/knit_print_template.qmd b/tests/testthat/fixtures/knit_print_template.Rmd similarity index 75% rename from tests/testthat/fixtures/knit_print_template.qmd rename to tests/testthat/fixtures/knit_print_template.Rmd index 044e8c419..3c4ffecc7 100644 --- a/tests/testthat/fixtures/knit_print_template.qmd +++ b/tests/testthat/fixtures/knit_print_template.Rmd @@ -1,15 +1,11 @@ --- title: "Test" -format: html -editor: visual -embed-resources: true +output: html_document params: class_name: "CohortSizeConst" --- -```{r} -#| echo: FALSE - +```{r, echo=FALSE} suppressPackageStartupMessages({ devtools::load_all() library(knitr) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index d5e50cbdb..8225fc537 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -29,8 +29,8 @@ test_that("knit_print methods exist for all relevant classes and produce consist # Temporarily change the working directory because Quarto can't specify # location of output file # See https://github.com/quarto-dev/quarto-r/issues/81 - withr::with_dir( - test_path("fixtures"), + # withr::with_dir( + # test_path("fixtures"), { # For each relevant class... for (cls in crmpack_class_list) { @@ -49,12 +49,13 @@ test_that("knit_print methods exist for all relevant classes and produce consist withr::with_file( outFileName, { - quarto::quarto_render( - input = test_path("knit_print_template.qmd"), - execute_params = list("class_name" = cls), - output_file = outFileName + rmarkdown::render( + input = test_path(file.path("fixtures", "knit_print_template.qmd")), + params = list("class_name" = cls), + output_file = outFileName, + output_dir = test_path("fixtures") ) - expect_snapshot_file(outFileName) + expect_snapshot_file(test_path(file.path("fixtures", outFileName))) } ) } @@ -63,7 +64,7 @@ test_that("knit_print methods exist for all relevant classes and produce consist } } } - ) + # ) }) # CohortSize --- @@ -73,19 +74,19 @@ test_that("knit_print methods exist for all relevant classes and produce consist test_that("knit_print.CohortSizeConst works correctly", { x <- CohortSizeConst(3) rv <- knit_print(x) - expect_equal(rv, "A constant size of 3 participants", ignore_attr = TRUE) + expect_equal(rv, "A constant size of 3 participants.", ignore_attr = TRUE) expect_class(rv, "knit_asis") x <- CohortSizeConst(2) rv <- knit_print(x, label = "subject") - expect_equal(rv, "A constant size of 2 subjects", ignore_attr = TRUE) + expect_equal(rv, "A constant size of 2 subjects.", ignore_attr = TRUE) x <- CohortSizeConst(1) rv <- knit_print(x, label = "subject") - expect_equal(rv, "A constant size of 1 subject", ignore_attr = TRUE) + expect_equal(rv, "A constant size of 1 subject.", ignore_attr = TRUE) x <- CohortSizeConst(3) rv <- knit_print(x, asis = FALSE) - expect_equal(rv, "A constant size of 3 participants") + expect_equal(rv, "A constant size of 3 participants.") expect_class(rv, "character") }) From 26bc9ab27ce5b3fc998f7f64580481e572f75bcc Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:06:40 +0000 Subject: [PATCH 12/26] [skip actions] Restyle files --- tests/testthat/test-helpers_knitr.R | 58 ++++++++++++++--------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 8225fc537..20f30fbf3 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -31,39 +31,39 @@ test_that("knit_print methods exist for all relevant classes and produce consist # See https://github.com/quarto-dev/quarto-r/issues/81 # withr::with_dir( # test_path("fixtures"), - { - # For each relevant class... - for (cls in crmpack_class_list) { - if (!isClassUnion(cls)) { - # Obtain the corresponding knit_print method... - methodName <- identifyMethod( - knit_print, - do.call(paste0(".Default", cls), list()) + { + # For each relevant class... + for (cls in crmpack_class_list) { + if (!isClassUnion(cls)) { + # Obtain the corresponding knit_print method... + methodName <- identifyMethod( + knit_print, + do.call(paste0(".Default", cls), list()) + ) + # ... and if the default has been overridden, test it + if (methodName != "knit_print.default") { + outFileName <- paste0("knit_print_", cls, ".html") + # with_file guarantees that the test file will be deleted automatically + # once the snapshot has been compared with the previous version, which + # can be found in /_snaps/helpers_knitr + withr::with_file( + outFileName, + { + rmarkdown::render( + input = test_path(file.path("fixtures", "knit_print_template.qmd")), + params = list("class_name" = cls), + output_file = outFileName, + output_dir = test_path("fixtures") + ) + expect_snapshot_file(test_path(file.path("fixtures", outFileName))) + } ) - # ... and if the default has been overridden, test it - if (methodName != "knit_print.default") { - outFileName <- paste0("knit_print_", cls, ".html") - # with_file guarantees that the test file will be deleted automatically - # once the snapshot has been compared with the previous version, which - # can be found in /_snaps/helpers_knitr - withr::with_file( - outFileName, - { - rmarkdown::render( - input = test_path(file.path("fixtures", "knit_print_template.qmd")), - params = list("class_name" = cls), - output_file = outFileName, - output_dir = test_path("fixtures") - ) - expect_snapshot_file(test_path(file.path("fixtures", outFileName))) - } - ) - } - } else { - warning(paste0("No default constructor for ", cls)) } + } else { + warning(paste0("No default constructor for ", cls)) } } + } # ) }) From 8dfe5aa9c0e8fe32feb219309e92eb48919bfabf Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 15:09:12 +0000 Subject: [PATCH 13/26] Fix lintr errors --- tests/testthat/test-helpers_knitr.R | 62 +++++++++++++---------------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 8225fc537..9be6e8334 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -26,45 +26,37 @@ test_that("knit_print methods exist for all relevant classes and produce consist X(...) } - # Temporarily change the working directory because Quarto can't specify - # location of output file - # See https://github.com/quarto-dev/quarto-r/issues/81 - # withr::with_dir( - # test_path("fixtures"), - { - # For each relevant class... - for (cls in crmpack_class_list) { - if (!isClassUnion(cls)) { - # Obtain the corresponding knit_print method... - methodName <- identifyMethod( - knit_print, - do.call(paste0(".Default", cls), list()) - ) - # ... and if the default has been overridden, test it - if (methodName != "knit_print.default") { - outFileName <- paste0("knit_print_", cls, ".html") - # with_file guarantees that the test file will be deleted automatically - # once the snapshot has been compared with the previous version, which - # can be found in /_snaps/helpers_knitr - withr::with_file( - outFileName, - { - rmarkdown::render( - input = test_path(file.path("fixtures", "knit_print_template.qmd")), - params = list("class_name" = cls), - output_file = outFileName, - output_dir = test_path("fixtures") - ) - expect_snapshot_file(test_path(file.path("fixtures", outFileName))) - } + # For each relevant class... + for (cls in crmpack_class_list) { + if (!isClassUnion(cls)) { + # Obtain the corresponding knit_print method... + methodName <- identifyMethod( + knit_print, + do.call(paste0(".Default", cls), list()) + ) + # ... and if the default has been overridden, test it + if (methodName != "knit_print.default") { + outFileName <- paste0("knit_print_", cls, ".html") + # with_file guarantees that the test file will be deleted automatically + # once the snapshot has been compared with the previous version, which + # can be found in /_snaps/helpers_knitr + withr::with_file( + outFileName, + { + rmarkdown::render( + input = test_path(file.path("fixtures", "knit_print_template.qmd")), + params = list("class_name" = cls), + output_file = outFileName, + output_dir = test_path("fixtures") ) + expect_snapshot_file(test_path(file.path("fixtures", outFileName))) } - } else { - warning(paste0("No default constructor for ", cls)) - } + ) } + } else { + warning(paste0("No default constructor for ", cls)) } - # ) + } }) # CohortSize --- From 22c79e0ad2834897f4ceb99ef6f21930e01aa7b0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:13:04 +0000 Subject: [PATCH 14/26] [skip actions] Restyle files --- tests/testthat/test-helpers_knitr.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index bb0e2c606..fce3833bf 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -29,7 +29,7 @@ test_that("knit_print methods exist for all relevant classes and produce consist for (cls in crmpack_class_list) { if (!isClassUnion(cls)) { # Obtain the corresponding knit_print method... - methodName <- identifyMethod( + methodName <- identifyMethod( knit_print, do.call(paste0(".Default", cls), list()) ) @@ -53,7 +53,7 @@ test_that("knit_print methods exist for all relevant classes and produce consist ) } } else { - warning(paste0("No default constructor for ", cls)) + warning(paste0("No default constructor for ", cls)) } } }) From d4c94014e88a025a9e10fcca123c9d47f035ba1c Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Thu, 1 Feb 2024 16:42:11 +0000 Subject: [PATCH 15/26] Typo --- tests/testthat/test-helpers_knitr.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index bb0e2c606..0bf93de92 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -43,7 +43,7 @@ test_that("knit_print methods exist for all relevant classes and produce consist outFileName, { rmarkdown::render( - input = test_path(file.path("fixtures", "knit_print_template.qmd")), + input = test_path(file.path("fixtures", "knit_print_template.Rmd")), params = list("class_name" = cls), output_file = outFileName, output_dir = test_path("fixtures") From c5997cde1f9cb6c60f04daf88ac6194903bb3907 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Fri, 2 Feb 2024 09:13:46 +0000 Subject: [PATCH 16/26] Allow knit_print tests to work in GitHub actions as well as in devtools:;check() etc --- tests/testthat/test-helpers_knitr.R | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 0d4fe698f..8b2cc2503 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -43,12 +43,12 @@ test_that("knit_print methods exist for all relevant classes and produce consist outFileName, { rmarkdown::render( - input = test_path(file.path("fixtures", "knit_print_template.Rmd")), + input = test_path("fixtures", "knit_print_template.Rmd"), params = list("class_name" = cls), output_file = outFileName, output_dir = test_path("fixtures") ) - expect_snapshot_file(test_path(file.path("fixtures", outFileName))) + expect_snapshot_file(test_path("fixtures", outFileName)) } ) } @@ -81,3 +81,26 @@ test_that("knit_print.CohortSizeConst works correctly", { expect_equal(rv, "A constant size of 3 participants.") expect_class(rv, "character") }) + +# CohortSizeParts + +test_that("knit_print.CohortSizeParts works correctly", { + x <- CohortSizeParts(c(1, 3)) + rv <- knit_print(x) + expect_equal(rv, "A size of 1 participant in the first part and 3 participants in the second.", ignore_attr = TRUE) + expect_class(rv, "knit_asis") + + x <- CohortSizeParts(c(1, 3)) + rv <- knit_print(x, label = "subject") + expect_equal(rv, "A size of 1 subject in the first part and 3 subjects in the second.", ignore_attr = TRUE) + + x <- CohortSizeParts(c(1, 3)) + rv <- knit_print(x, label = "subject") + expect_equal(rv, "A size of 1 subject in the first part and 3 subjects in the second.", ignore_attr = TRUE) + + x <- CohortSizeParts(c(1, 3)) + rv <- knit_print(x, asis = FALSE) + expect_equal(rv, "A size of 1 participant in the first part and 3 participants in the second.") + expect_class(rv, "character") +}) + From 09e6060d737aea01ba07a5856840aff86f4dbd53 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:16:13 +0000 Subject: [PATCH 17/26] [skip actions] Restyle files --- tests/testthat/test-helpers_knitr.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 8b2cc2503..4f7a6de8d 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -103,4 +103,3 @@ test_that("knit_print.CohortSizeParts works correctly", { expect_equal(rv, "A size of 1 participant in the first part and 3 participants in the second.") expect_class(rv, "character") }) - From a06085a9cd6cc6ec29c03e27b1940ad84cddf756 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Fri, 2 Feb 2024 10:14:44 +0000 Subject: [PATCH 18/26] Skip knit_print tests during R CMD Check --- tests/testthat/test-helpers_knitr.R | 34 ++++++++++++++++------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 8b2cc2503..8221ddea1 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -36,21 +36,25 @@ test_that("knit_print methods exist for all relevant classes and produce consist # ... and if the default has been overridden, test it if (methodName != "knit_print.default") { outFileName <- paste0("knit_print_", cls, ".html") - # with_file guarantees that the test file will be deleted automatically - # once the snapshot has been compared with the previous version, which - # can be found in /_snaps/helpers_knitr - withr::with_file( - outFileName, - { - rmarkdown::render( - input = test_path("fixtures", "knit_print_template.Rmd"), - params = list("class_name" = cls), - output_file = outFileName, - output_dir = test_path("fixtures") - ) - expect_snapshot_file(test_path("fixtures", outFileName)) - } - ) + if (is_checking()) { + announce_snapshot_file(name = outFileName) + } else { + # with_file guarantees that the test file will be deleted automatically + # once the snapshot has been compared with the previous version, which + # can be found in /_snaps/helpers_knitr + withr::with_file( + outFileName, + { + rmarkdown::render( + input = test_path("fixtures", "knit_print_template.Rmd"), + params = list("class_name" = cls), + output_file = outFileName, + output_dir = test_path("fixtures") + ) + expect_snapshot_file(test_path("fixtures", outFileName)) + } + ) + } } } else { warning(paste0("No default constructor for ", cls)) From 302b2aeb557a4873a9f41421cecef2c98ef97634 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Fri, 2 Feb 2024 11:15:35 +0000 Subject: [PATCH 19/26] Revise knit_print tests --- R/helpers_knitr_CohortSize.R | 38 +++++++++---------- .../knit_print_CohortSizeConst.html | 1 - .../knit_print_CohortSizeDLT.html | 1 - .../knit_print_CohortSizeMax.html | 1 - .../knit_print_CohortSizeMin.html | 1 - .../knit_print_CohortSizeOrdinal.html | 1 - .../knit_print_CohortSizeParts.html | 1 - .../knit_print_CohortSizeRange.html | 1 - .../fixtures/knit_print_CohortSizeConst.html | 1 - .../fixtures/knit_print_CohortSizeDLT.html | 1 - .../fixtures/knit_print_CohortSizeMax.html | 1 - .../fixtures/knit_print_CohortSizeMin.html | 1 - .../knit_print_CohortSizeOrdinal.html | 1 - .../fixtures/knit_print_CohortSizeParts.html | 1 - .../fixtures/knit_print_CohortSizeRange.html | 1 - .../testthat/fixtures/knit_print_template.Rmd | 8 +++- 16 files changed, 25 insertions(+), 35 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 53d2ca535..b087810dc 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -18,7 +18,7 @@ NULL #' Render a CohortSizeConst Object #' #' @description `r lifecycle::badge("experimental")` -#' @param obj (`CohortSize`)\cr The object to knit_print. +#' @param x (`CohortSize`)\cr The object to knit_print. #' @param asis (`flag`)\cr Should the return value be wrapped in a call to `knitr::asis_output`? #' @param label (`character`)\cr The word used to label the participants. See Usage Notes below. #' @param ... Not used at present @@ -35,14 +35,14 @@ NULL #' #' @export #' @rdname knit_print -knit_print.CohortSizeConst <- function(obj, ..., asis = TRUE, label = c("participant", "participants")) { +knit_print.CohortSizeConst <- function(x, ..., asis = TRUE, label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) if (length(label) == 1) { label[2] <- paste0(label[1], "s") } - rv <- paste0("A constant size of ", obj@size, " ", label[ifelse(obj@size == 1, 1, 2)], ".") + rv <- paste0("A constant size of ", x@size, " ", label[ifelse(x@size == 1, 1, 2)], ".") if (asis) { rv <- knitr::asis_output(rv) } @@ -57,7 +57,7 @@ registerS3method("knit_print", "CohortSizeConst", knit_print.CohortSizeConst) #' #' @export #' @rdname knit_print -knit_print.CohortSizeRange <- function(obj, ..., asis = TRUE) { +knit_print.CohortSizeRange <- function(x, ..., asis = TRUE) { assert_flag(asis) param <- list(...) @@ -67,7 +67,7 @@ knit_print.CohortSizeRange <- function(obj, ..., asis = TRUE) { if (!("caption" %in% names(param))) { param[["caption"]] <- "Defined by the dose to be used in the next cohort" } - x <- obj %>% tidy() + x <- x %>% tidy() param[["x"]] <- x rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("Dose" = 2, " " = 1)) @@ -91,7 +91,7 @@ registerS3method("knit_print", "CohortSizeRange", knit_print.CohortSizeRange) #' #' @export #' @rdname knit_print -knit_print.CohortSizeDLT <- function(obj, ..., asis = TRUE) { +knit_print.CohortSizeDLT <- function(x, ..., asis = TRUE) { assert_flag(asis) param <- list(...) @@ -101,7 +101,7 @@ knit_print.CohortSizeDLT <- function(obj, ..., asis = TRUE) { if (!("caption" %in% names(param))) { param[["caption"]] <- "Defined by the number of DLTs so far observed" } - param[["x"]] <- obj %>% tidy() + param[["x"]] <- x %>% tidy() rv <- do.call(knitr::kable, param) %>% kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) if (asis) { @@ -119,7 +119,7 @@ registerS3method("knit_print", "CohortSizeDLT", knit_print.CohortSizeDLT) #' #' @export #' @rdname knit_print -knit_print.CohortSizeParts <- function(obj, ..., asis = TRUE, label = c("participant", "participants")) { +knit_print.CohortSizeParts <- function(x, ..., asis = TRUE, label = c("participant", "participants")) { assert_character(label, min.len = 1, max.len = 2, any.missing = FALSE) assert_flag(asis) @@ -128,13 +128,13 @@ knit_print.CohortSizeParts <- function(obj, ..., asis = TRUE, label = c("partici } rv <- paste0( "A size of ", - obj@cohort_sizes[1], + x@cohort_sizes[1], " ", - label[ifelse(obj@cohort_sizes[1] == 1, 1, 2)], + label[ifelse(x@cohort_sizes[1] == 1, 1, 2)], " in the first part and ", - obj@cohort_sizes[2], + x@cohort_sizes[2], " ", - label[ifelse(obj@cohort_sizes[2] == 1, 1, 2)], + label[ifelse(x@cohort_sizes[2] == 1, 1, 2)], " in the second." ) if (asis) { @@ -153,13 +153,13 @@ registerS3method("knit_print", "CohortSizeParts", knit_print.CohortSizeParts) #' #' @export #' @rdname knit_print -knit_print.CohortSizeMax <- function(obj, ..., asis = TRUE) { +knit_print.CohortSizeMax <- function(x, ..., asis = TRUE) { assert_flag(asis) rv <- paste0( "The maximum of the cohort sizes defined in the following rules:", paste0( lapply( - obj@cohort_sizes, + x@cohort_sizes, function(x, ...) { knit_print(x, asis = asis, ...) } @@ -185,13 +185,13 @@ registerS3method("knit_print", "CohortSizeMax", knit_print.CohortSizeMax) #' #' @export #' @rdname knit_print -knit_print.CohortSizeMin <- function(obj, ..., asis = TRUE) { +knit_print.CohortSizeMin <- function(x, ..., asis = TRUE) { assert_flag(asis) rv <- paste0( "The minimum of the cohort sizes defined in the following rules:", paste0( lapply( - obj@cohort_sizes, + x@cohort_sizes, function(x, ...) { knit_print(x, asis = asis, ...) } @@ -215,13 +215,13 @@ registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' #' @export #' @rdname knit_print -knit_print.CohortSizeOrdinal <- function(obj, ..., asis = TRUE) { +knit_print.CohortSizeOrdinal <- function(x, ..., asis = TRUE) { knitr::asis_output( paste0( "Based on a toxicity grade of ", - obj@grade, + x@grade, ": ", - paste0(knit_print(obj@rule, asis = asis, ...), collapse = "\n"), + paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), paste = "\n" ) ) diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html index 7f5ae1ce7..8158d88c2 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeConst.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeConst"

A constant size of 3 participants.

diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html index f1bae7849..7e2c7aa11 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeDLT.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeDLT"
diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html index f74cef1e0..cde60b024 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMax.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeMax"
The maximum of the cohort sizes defined in the following rules: diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html index fe4dfe8ee..8bb7cee1e 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeMin.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeMin"
The minimum of the cohort sizes defined in the following rules:
diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html index adbca6d62..cf91607a3 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeOrdinal.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeOrdinal"
Based on a toxicity grade of 1:
diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html index adb4e99fa..47ac5f9c0 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeParts.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeParts"

A size of 1 participant in the first part and 3 participants in the second.

diff --git a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html index 0917d5823..1e8def946 100644 --- a/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html +++ b/tests/testthat/_snaps/helpers_knitr/knit_print_CohortSizeRange.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeRange"
diff --git a/tests/testthat/fixtures/knit_print_CohortSizeConst.html b/tests/testthat/fixtures/knit_print_CohortSizeConst.html index 7f5ae1ce7..8158d88c2 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeConst.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeConst.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeConst"

A constant size of 3 participants.

diff --git a/tests/testthat/fixtures/knit_print_CohortSizeDLT.html b/tests/testthat/fixtures/knit_print_CohortSizeDLT.html index f1bae7849..7e2c7aa11 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeDLT.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeDLT.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeDLT"
diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMax.html b/tests/testthat/fixtures/knit_print_CohortSizeMax.html index f74cef1e0..cde60b024 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeMax.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeMax.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeMax"
The maximum of the cohort sizes defined in the following rules: diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMin.html b/tests/testthat/fixtures/knit_print_CohortSizeMin.html index fe4dfe8ee..8bb7cee1e 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeMin.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeMin.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeMin"
The minimum of the cohort sizes defined in the following rules:
diff --git a/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html b/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html index adbca6d62..cf91607a3 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeOrdinal"
Based on a toxicity grade of 1:
diff --git a/tests/testthat/fixtures/knit_print_CohortSizeParts.html b/tests/testthat/fixtures/knit_print_CohortSizeParts.html index adb4e99fa..47ac5f9c0 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeParts.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeParts.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeParts"

A size of 1 participant in the first part and 3 participants in the second.

diff --git a/tests/testthat/fixtures/knit_print_CohortSizeRange.html b/tests/testthat/fixtures/knit_print_CohortSizeRange.html index 0917d5823..1e8def946 100644 --- a/tests/testthat/fixtures/knit_print_CohortSizeRange.html +++ b/tests/testthat/fixtures/knit_print_CohortSizeRange.html @@ -353,7 +353,6 @@

Test

-
## i Loading crmPack
## [1] "CohortSizeRange"
diff --git a/tests/testthat/fixtures/knit_print_template.Rmd b/tests/testthat/fixtures/knit_print_template.Rmd index 3c4ffecc7..d47dbefdc 100644 --- a/tests/testthat/fixtures/knit_print_template.Rmd +++ b/tests/testthat/fixtures/knit_print_template.Rmd @@ -7,8 +7,12 @@ params: ```{r, echo=FALSE} suppressPackageStartupMessages({ - devtools::load_all() - library(knitr) +if (file.exists("DESCRIPTION")) { + devtools::load_all(export_all = FALSE) +} else { + library(crmPack) +} +library(knitr) }) print(params$class_name) From 314c77f035d21c7a423d20eee79daecc2577828b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 2 Feb 2024 11:18:08 +0000 Subject: [PATCH 20/26] [skip actions] Restyle files --- tests/testthat/fixtures/knit_print_template.Rmd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/testthat/fixtures/knit_print_template.Rmd b/tests/testthat/fixtures/knit_print_template.Rmd index d47dbefdc..a667deb88 100644 --- a/tests/testthat/fixtures/knit_print_template.Rmd +++ b/tests/testthat/fixtures/knit_print_template.Rmd @@ -7,12 +7,12 @@ params: ```{r, echo=FALSE} suppressPackageStartupMessages({ -if (file.exists("DESCRIPTION")) { - devtools::load_all(export_all = FALSE) -} else { - library(crmPack) -} -library(knitr) + if (file.exists("DESCRIPTION")) { + devtools::load_all(export_all = FALSE) + } else { + library(crmPack) + } + library(knitr) }) print(params$class_name) From e3a67f79f45ebbeb667c837bb6b98d21201ce39c Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Fri, 2 Feb 2024 13:15:49 +0000 Subject: [PATCH 21/26] Updating docs --- man/knit_print.Rd | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/man/knit_print.Rd b/man/knit_print.Rd index 21da22511..2254a27a7 100644 --- a/man/knit_print.Rd +++ b/man/knit_print.Rd @@ -11,22 +11,22 @@ \alias{knit_print.CohortSizeOrdinal} \title{Render a CohortSizeConst Object} \usage{ -\method{knit_print}{CohortSizeConst}(obj, ..., asis = TRUE, label = c("participant", "participants")) +\method{knit_print}{CohortSizeConst}(x, ..., asis = TRUE, label = c("participant", "participants")) -\method{knit_print}{CohortSizeRange}(obj, ..., asis = TRUE) +\method{knit_print}{CohortSizeRange}(x, ..., asis = TRUE) -\method{knit_print}{CohortSizeDLT}(obj, ..., asis = TRUE) +\method{knit_print}{CohortSizeDLT}(x, ..., asis = TRUE) -\method{knit_print}{CohortSizeParts}(obj, ..., asis = TRUE, label = c("participant", "participants")) +\method{knit_print}{CohortSizeParts}(x, ..., asis = TRUE, label = c("participant", "participants")) -\method{knit_print}{CohortSizeMax}(obj, ..., asis = TRUE) +\method{knit_print}{CohortSizeMax}(x, ..., asis = TRUE) -\method{knit_print}{CohortSizeMin}(obj, ..., asis = TRUE) +\method{knit_print}{CohortSizeMin}(x, ..., asis = TRUE) -\method{knit_print}{CohortSizeOrdinal}(obj, ..., asis = TRUE) +\method{knit_print}{CohortSizeOrdinal}(x, ..., asis = TRUE) } \arguments{ -\item{obj}{(\code{CohortSize})\cr The object to knit_print.} +\item{x}{(\code{CohortSize})\cr The object to knit_print.} \item{...}{passed through to the \code{knit_print} method of the standard rule} From a21575fd2a06f028de3feb6c59afd5038bf0d363 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Mon, 5 Feb 2024 12:09:53 +0000 Subject: [PATCH 22/26] Respond to review comments --- R/helpers_knitr_CohortSize.R | 31 +- .../fixtures/knit_print_CohortSizeConst.html | 405 -------------- .../fixtures/knit_print_CohortSizeDLT.html | 455 ---------------- .../fixtures/knit_print_CohortSizeMax.html | 507 ------------------ .../fixtures/knit_print_CohortSizeMin.html | 507 ------------------ .../knit_print_CohortSizeOrdinal.html | 456 ---------------- .../fixtures/knit_print_CohortSizeParts.html | 406 -------------- .../fixtures/knit_print_CohortSizeRange.html | 455 ---------------- tests/testthat/test-helpers_knitr.R | 123 +++-- 9 files changed, 100 insertions(+), 3245 deletions(-) delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeConst.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeDLT.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeMax.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeMin.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeParts.html delete mode 100644 tests/testthat/fixtures/knit_print_CohortSizeRange.html diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index b087810dc..2464fc35f 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -48,7 +48,6 @@ knit_print.CohortSizeConst <- function(x, ..., asis = TRUE, label = c("participa } rv } -registerS3method("knit_print", "CohortSizeConst", knit_print.CohortSizeConst) #' Render a CohortSizeRange Object #' @@ -67,16 +66,17 @@ knit_print.CohortSizeRange <- function(x, ..., asis = TRUE) { if (!("caption" %in% names(param))) { param[["caption"]] <- "Defined by the dose to be used in the next cohort" } - x <- x %>% tidy() + x <- tidy(x) param[["x"]] <- x - rv <- do.call(knitr::kable, param) %>% - kableExtra::add_header_above(c("Dose" = 2, " " = 1)) + rv <- kableExtra::add_header_above( + do.call(knitr::kable, param), + c("Dose" = 2, " " = 1) + ) if (asis) { rv <- knitr::asis_output(rv) } rv } -registerS3method("knit_print", "CohortSizeRange", knit_print.CohortSizeRange) #' Render a CohortSizeDLT Object #' @@ -101,15 +101,16 @@ knit_print.CohortSizeDLT <- function(x, ..., asis = TRUE) { if (!("caption" %in% names(param))) { param[["caption"]] <- "Defined by the number of DLTs so far observed" } - param[["x"]] <- x %>% tidy() - rv <- do.call(knitr::kable, param) %>% - kableExtra::add_header_above(c("No of DLTs" = 2, " " = 1)) + param[["x"]] <- tidy(x) + rv <- kableExtra::add_header_above( + do.call(knitr::kable, param), + c("No of DLTs" = 2, " " = 1) + ) if (asis) { rv <- knitr::asis_output(rv) } rv } -registerS3method("knit_print", "CohortSizeDLT", knit_print.CohortSizeDLT) #' Render a CohortSizeParts Object #' @@ -142,7 +143,6 @@ knit_print.CohortSizeParts <- function(x, ..., asis = TRUE, label = c("participa } rv } -registerS3method("knit_print", "CohortSizeParts", knit_print.CohortSizeParts) #' Render a CohortSizeMax Object #' @@ -174,7 +174,6 @@ knit_print.CohortSizeMax <- function(x, ..., asis = TRUE) { } rv } -registerS3method("knit_print", "CohortSizeMax", knit_print.CohortSizeMax) #' Render a CohortSizeMin Object #' @@ -205,7 +204,6 @@ knit_print.CohortSizeMin <- function(x, ..., asis = TRUE) { } rv } -registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' Render a CohortSizeOrdinal Object #' @@ -216,14 +214,15 @@ registerS3method("knit_print", "CohortSizeMin", knit_print.CohortSizeMin) #' @export #' @rdname knit_print knit_print.CohortSizeOrdinal <- function(x, ..., asis = TRUE) { - knitr::asis_output( - paste0( + rv <- paste0( "Based on a toxicity grade of ", x@grade, ": ", paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), paste = "\n" ) - ) + if (asis){ + rv <- knitr::asis_output(rv) + } + rv } -registerS3method("knit_print", "CohortSizeOrdinal", knit_print.CohortSizeOrdinal) diff --git a/tests/testthat/fixtures/knit_print_CohortSizeConst.html b/tests/testthat/fixtures/knit_print_CohortSizeConst.html deleted file mode 100644 index 8158d88c2..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeConst.html +++ /dev/null @@ -1,405 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeConst"
-

A constant size of 3 participants.

- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeDLT.html b/tests/testthat/fixtures/knit_print_CohortSizeDLT.html deleted file mode 100644 index 7e2c7aa11..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeDLT.html +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeDLT"
- - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the number of DLTs so far observed -
-
-No of DLTs -
-
-
-Lower - -Upper - -Cohort size -
-0 - -1 - -1 -
-1 - -Inf - -3 -
- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMax.html b/tests/testthat/fixtures/knit_print_CohortSizeMax.html deleted file mode 100644 index cde60b024..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeMax.html +++ /dev/null @@ -1,507 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeMax"
-The maximum of the cohort sizes defined in the following rules: - - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the dose to be used in the next cohort -
-
-Dose -
-
-
-Lower - -Upper - -Cohort size -
-0 - -10 - -1 -
-10 - -Inf - -3 -
- - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the number of DLTs so far observed -
-
-No of DLTs -
-
-
-Lower - -Upper - -Cohort size -
-0 - -1 - -1 -
-1 - -Inf - -3 -
- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeMin.html b/tests/testthat/fixtures/knit_print_CohortSizeMin.html deleted file mode 100644 index 8bb7cee1e..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeMin.html +++ /dev/null @@ -1,507 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeMin"
-The minimum of the cohort sizes defined in the following rules: - - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the dose to be used in the next cohort -
-
-Dose -
-
-
-Lower - -Upper - -Cohort size -
-0 - -10 - -1 -
-10 - -Inf - -3 -
- - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the number of DLTs so far observed -
-
-No of DLTs -
-
-
-Lower - -Upper - -Cohort size -
-0 - -1 - -1 -
-1 - -Inf - -3 -
- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html b/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html deleted file mode 100644 index cf91607a3..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeOrdinal.html +++ /dev/null @@ -1,456 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeOrdinal"
-Based on a toxicity grade of 1: - - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the dose to be used in the next cohort -
-
-Dose -
-
-
-Lower - -Upper - -Cohort size -
-0 - -30 - -1 -
-30 - -Inf - -3 -
- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeParts.html b/tests/testthat/fixtures/knit_print_CohortSizeParts.html deleted file mode 100644 index 47ac5f9c0..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeParts.html +++ /dev/null @@ -1,406 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeParts"
-

A size of 1 participant in the first part and 3 participants in the -second.

- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/fixtures/knit_print_CohortSizeRange.html b/tests/testthat/fixtures/knit_print_CohortSizeRange.html deleted file mode 100644 index 1e8def946..000000000 --- a/tests/testthat/fixtures/knit_print_CohortSizeRange.html +++ /dev/null @@ -1,455 +0,0 @@ - - - - - - - - - - - - - -Test - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
## [1] "CohortSizeRange"
- - - - - - - - - - - - - - - - - - - - - - - - - -
-Defined by the dose to be used in the next cohort -
-
-Dose -
-
-
-Lower - -Upper - -Cohort size -
-0 - -30 - -1 -
-30 - -Inf - -3 -
- - - - -
- - - - - - - - - - - - - - - diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 561fa2013..dd73a0f5c 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -1,50 +1,82 @@ library(knitr) -if (!testthat::is_checking()) { - devtools::load_all() +# if (!testthat::is_checking()) { +# devtools::load_all() +# } + +# h_custom_method_exists could be removed once all necessary knit_print methods +# have been defined + +#' Test if a Class-Specific S3 Generic Exists +#' +#' @param generic (`name`)\cr The unquoted name of the generic, which must exist +#' @param obj (`ANY`)\cr An S3 or S4 object +#' @return TRUE if S3 method `.` exists, FALSE otherwise +#' @example h_custom_method_exists(knit_print, "CohortSizeConst") # TRUE +#' @example h_custom_method_exists(knot_print, "Validate") # FALSE +#' @internal +h_custom_method_exists <- function(generic, obj) { + # See https://stackoverflow.com/questions/42738851/r-how-to-find-what-s3-method-will-be-called-on-an-object + generic_name <- deparse(substitute(generic)) + f <- X <- function(x, obj) UseMethod("X") + for (m in methods(generic_name)) assign(sub(generic_name, "X", m, fixed = TRUE), "body<-"(f, value = m)) + method_name <- X(obj) + return (method_name != paste0(generic_name, ".default")) } -test_that("knit_print methods exist for all relevant classes and produce consistent output", { - crmpack_class_list <- getClasses(asNamespace("crmPack")) - exclusions <- c( - "CohortSize", "CrmPackClass", "DualEndpoint", "GeneralData", "GeneralModel", - "GeneralSimulationsSummary", "Increments", "ModelEff", "ModelPseudo", - "ModelTox", "NextBest", "positive_number", "PseudoSimulations", - "PseudoDualSimulations", "PseudoDualSimulationsSummary", - "PseudoDualFlexiSimulations", "PseudoFlexiSimulations", - "PseudoSimulationsSummary", "SimulationsSummary", "Report", "SafetyWindow", - "Stopping", "Validate", - # The following classes have no constructors - "DualSimulationsSummary" +test_that("h_custom_method_exists works correctly", { + withr::with_environment( + .GlobalEnv, + { + foo <<- function(x, ...) UseMethod("foo") + bar <<- NA + class(bar) <- "bar" + baz <<- NA + class(baz) <- "baz" + foo.default <<- function(x, ...) "I don't know what to do" + foo.bar <<- function(x, ...) "I am bar" + withr::defer(rm(foo, bar, baz, foo.default, foo.bar, envir = .GlobalEnv)) + + expect_true(h_custom_method_exists(foo, bar)) + expect_false(h_custom_method_exists(foo, baz)) + } ) - crmpack_class_list <- setdiff(crmpack_class_list, exclusions) +}) - # See https://stackoverflow.com/questions/42738851/r-how-to-find-what-s3-method-will-be-called-on-an-object - identifyMethod <- function(generic, ...) { - ch <- deparse(substitute(generic)) - f <- X <- function(x, ...) UseMethod("X") - for (m in methods(ch)) assign(sub(ch, "X", m, fixed = TRUE), "body<-"(f, value = m)) - X(...) - } +test_that("Global environment is clean after testing h_custom_method_exists", { + expect_false(exists("foo")) + expect_false(exists("bar")) + expect_false(exists("baz")) + expect_false(exists("foo.bar")) + expect_false(exists("foo.default")) +}) +crmpack_class_list <- getClasses(asNamespace("crmPack")) +exclusions <- c( + "CohortSize", "CrmPackClass", "DualEndpoint", "GeneralData", "GeneralModel", + "GeneralSimulationsSummary", "Increments", "ModelEff", "ModelPseudo", + "ModelTox", "NextBest", "positive_number", "PseudoSimulations", + "PseudoDualSimulations", "PseudoDualSimulationsSummary", + "PseudoDualFlexiSimulations", "PseudoFlexiSimulations", + "PseudoSimulationsSummary", "SimulationsSummary", "Report", "SafetyWindow", + "Stopping", "Validate", + # The following classes have no constructors + "DualSimulationsSummary" +) +crmpack_class_list <- setdiff(crmpack_class_list, exclusions) + +test_that("knit_print methods exist for all relevant classes and produce consistent output", { for (cls in crmpack_class_list) { if (!isClassUnion(cls)) { - # Obtain the corresponding knit_print method... - methodName <- identifyMethod( - knit_print, - do.call(paste0(".Default", cls), list()) - ) - # ... and if the default has been overridden, test it - if (methodName != "knit_print.default") { + # If the default knit_print method has been overridden, test it + if (h_custom_method_exists(knit_print, do.call(paste0(".Default", cls), list()))) { outFileName <- paste0("knit_print_", cls, ".html") - if (is_checking()) { - announce_snapshot_file(name = outFileName) - } else { # with_file guarantees that the test file will be deleted automatically # once the snapshot has been compared with the previous version, which # can be found in /_snaps/helpers_knitr withr::with_file( - outFileName, + test_path("fixtures", outFileName), { + # Code run in the template does not contribute to test coverage rmarkdown::render( input = test_path("fixtures", "knit_print_template.Rmd"), params = list("class_name" = cls), @@ -54,7 +86,6 @@ test_that("knit_print methods exist for all relevant classes and produce consist expect_snapshot_file(test_path("fixtures", outFileName)) } ) - } } } else { warning(paste0("No default constructor for ", cls)) @@ -62,6 +93,26 @@ test_that("knit_print methods exist for all relevant classes and produce consist } }) +test_that("asis parameter works correctly for all implemented methods", { + for (cls in crmpack_class_list) { + if (!isClassUnion(cls)) { + obj <- do.call(paste0(".Default", cls), list()) + # If the default knit_print method has been overridden, test it + if (h_custom_method_exists(knit_print, obj)) { + rv <- knit_print(obj) + expect_class(rv, "knit_asis") + rv <- knit_print(obj, asis = TRUE) + expect_class(rv, "knit_asis") + rv <- knit_print(obj, asis = FALSE) + # Most objects return a character, but not all. For example, + # CohortSizeDLT returns a knitr_table + if ("knit_asis" %in% class(rv)) print(cls) + expect_true(!("knit_asis" %in% class(rv))) + } + } + } +}) + # CohortSize --- # CohortSizeConst @@ -70,7 +121,6 @@ test_that("knit_print.CohortSizeConst works correctly", { x <- CohortSizeConst(3) rv <- knit_print(x) expect_equal(rv, "A constant size of 3 participants.", ignore_attr = TRUE) - expect_class(rv, "knit_asis") x <- CohortSizeConst(2) rv <- knit_print(x, label = "subject") @@ -83,7 +133,6 @@ test_that("knit_print.CohortSizeConst works correctly", { x <- CohortSizeConst(3) rv <- knit_print(x, asis = FALSE) expect_equal(rv, "A constant size of 3 participants.") - expect_class(rv, "character") }) # CohortSizeParts @@ -92,7 +141,6 @@ test_that("knit_print.CohortSizeParts works correctly", { x <- CohortSizeParts(c(1, 3)) rv <- knit_print(x) expect_equal(rv, "A size of 1 participant in the first part and 3 participants in the second.", ignore_attr = TRUE) - expect_class(rv, "knit_asis") x <- CohortSizeParts(c(1, 3)) rv <- knit_print(x, label = "subject") @@ -105,5 +153,4 @@ test_that("knit_print.CohortSizeParts works correctly", { x <- CohortSizeParts(c(1, 3)) rv <- knit_print(x, asis = FALSE) expect_equal(rv, "A size of 1 participant in the first part and 3 participants in the second.") - expect_class(rv, "character") }) From 066e1d6e38cda0dee3afdc2119a820b0a720d7fb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 12:12:21 +0000 Subject: [PATCH 23/26] [skip actions] Restyle files --- R/helpers_knitr_CohortSize.R | 16 +++++++------- tests/testthat/test-helpers_knitr.R | 34 ++++++++++++++--------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 2464fc35f..4ce7e716b 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -68,7 +68,7 @@ knit_print.CohortSizeRange <- function(x, ..., asis = TRUE) { } x <- tidy(x) param[["x"]] <- x - rv <- kableExtra::add_header_above( + rv <- kableExtra::add_header_above( do.call(knitr::kable, param), c("Dose" = 2, " " = 1) ) @@ -215,13 +215,13 @@ knit_print.CohortSizeMin <- function(x, ..., asis = TRUE) { #' @rdname knit_print knit_print.CohortSizeOrdinal <- function(x, ..., asis = TRUE) { rv <- paste0( - "Based on a toxicity grade of ", - x@grade, - ": ", - paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), - paste = "\n" - ) - if (asis){ + "Based on a toxicity grade of ", + x@grade, + ": ", + paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), + paste = "\n" + ) + if (asis) { rv <- knitr::asis_output(rv) } rv diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index dd73a0f5c..c84e4f551 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -20,7 +20,7 @@ h_custom_method_exists <- function(generic, obj) { f <- X <- function(x, obj) UseMethod("X") for (m in methods(generic_name)) assign(sub(generic_name, "X", m, fixed = TRUE), "body<-"(f, value = m)) method_name <- X(obj) - return (method_name != paste0(generic_name, ".default")) + return(method_name != paste0(generic_name, ".default")) } test_that("h_custom_method_exists works correctly", { @@ -70,22 +70,22 @@ test_that("knit_print methods exist for all relevant classes and produce consist # If the default knit_print method has been overridden, test it if (h_custom_method_exists(knit_print, do.call(paste0(".Default", cls), list()))) { outFileName <- paste0("knit_print_", cls, ".html") - # with_file guarantees that the test file will be deleted automatically - # once the snapshot has been compared with the previous version, which - # can be found in /_snaps/helpers_knitr - withr::with_file( - test_path("fixtures", outFileName), - { - # Code run in the template does not contribute to test coverage - rmarkdown::render( - input = test_path("fixtures", "knit_print_template.Rmd"), - params = list("class_name" = cls), - output_file = outFileName, - output_dir = test_path("fixtures") - ) - expect_snapshot_file(test_path("fixtures", outFileName)) - } - ) + # with_file guarantees that the test file will be deleted automatically + # once the snapshot has been compared with the previous version, which + # can be found in /_snaps/helpers_knitr + withr::with_file( + test_path("fixtures", outFileName), + { + # Code run in the template does not contribute to test coverage + rmarkdown::render( + input = test_path("fixtures", "knit_print_template.Rmd"), + params = list("class_name" = cls), + output_file = outFileName, + output_dir = test_path("fixtures") + ) + expect_snapshot_file(test_path("fixtures", outFileName)) + } + ) } } else { warning(paste0("No default constructor for ", cls)) From fe296a15028007ce6614e4a48053f43d4d7cf124 Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Mon, 5 Feb 2024 13:05:47 +0000 Subject: [PATCH 24/26] Fix lintr complaints --- R/helpers_knitr_CohortSize.R | 2 +- tests/testthat/test-helpers_knitr.R | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 2464fc35f..2832532be 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -221,7 +221,7 @@ knit_print.CohortSizeOrdinal <- function(x, ..., asis = TRUE) { paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), paste = "\n" ) - if (asis){ + if (asis) { rv <- knitr::asis_output(rv) } rv diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index dd73a0f5c..5575de881 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -1,7 +1,4 @@ library(knitr) -# if (!testthat::is_checking()) { -# devtools::load_all() -# } # h_custom_method_exists could be removed once all necessary knit_print methods # have been defined @@ -20,7 +17,7 @@ h_custom_method_exists <- function(generic, obj) { f <- X <- function(x, obj) UseMethod("X") for (m in methods(generic_name)) assign(sub(generic_name, "X", m, fixed = TRUE), "body<-"(f, value = m)) method_name <- X(obj) - return (method_name != paste0(generic_name, ".default")) + return(method_name != paste0(generic_name, ".default")) } test_that("h_custom_method_exists works correctly", { @@ -32,8 +29,8 @@ test_that("h_custom_method_exists works correctly", { class(bar) <- "bar" baz <<- NA class(baz) <- "baz" - foo.default <<- function(x, ...) "I don't know what to do" - foo.bar <<- function(x, ...) "I am bar" + foo.default <<- function(x, ...) "I don't know what to do" #nolint + foo.bar <<- function(x, ...) "I am bar" #nolint withr::defer(rm(foo, bar, baz, foo.default, foo.bar, envir = .GlobalEnv)) expect_true(h_custom_method_exists(foo, bar)) From d40d1ebfccdacccc343b96f638af834b45d1fa64 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 13:09:57 +0000 Subject: [PATCH 25/26] [skip actions] Restyle files --- R/helpers_knitr_CohortSize.R | 12 ++++++------ tests/testthat/test-helpers_knitr.R | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index d773b2cf5..8ab2aa080 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -215,12 +215,12 @@ knit_print.CohortSizeMin <- function(x, ..., asis = TRUE) { #' @rdname knit_print knit_print.CohortSizeOrdinal <- function(x, ..., asis = TRUE) { rv <- paste0( - "Based on a toxicity grade of ", - x@grade, - ": ", - paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), - paste = "\n" - ) + "Based on a toxicity grade of ", + x@grade, + ": ", + paste0(knit_print(x@rule, asis = asis, ...), collapse = "\n"), + paste = "\n" + ) if (asis) { rv <- knitr::asis_output(rv) diff --git a/tests/testthat/test-helpers_knitr.R b/tests/testthat/test-helpers_knitr.R index 99e36de21..cc77dfb45 100644 --- a/tests/testthat/test-helpers_knitr.R +++ b/tests/testthat/test-helpers_knitr.R @@ -29,8 +29,8 @@ test_that("h_custom_method_exists works correctly", { class(bar) <- "bar" baz <<- NA class(baz) <- "baz" - foo.default <<- function(x, ...) "I don't know what to do" #nolint - foo.bar <<- function(x, ...) "I am bar" #nolint + foo.default <<- function(x, ...) "I don't know what to do" # nolint + foo.bar <<- function(x, ...) "I am bar" # nolint withr::defer(rm(foo, bar, baz, foo.default, foo.bar, envir = .GlobalEnv)) expect_true(h_custom_method_exists(foo, bar)) From b629f795b4b7069a12e5ce806da279f4015842ca Mon Sep 17 00:00:00 2001 From: Puzzled-Face Date: Mon, 5 Feb 2024 13:54:06 +0000 Subject: [PATCH 26/26] Dummy commit to restart action --- R/helpers_knitr_CohortSize.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/helpers_knitr_CohortSize.R b/R/helpers_knitr_CohortSize.R index 8ab2aa080..6ab0c109f 100644 --- a/R/helpers_knitr_CohortSize.R +++ b/R/helpers_knitr_CohortSize.R @@ -3,7 +3,6 @@ NULL # Integration with knitr ---- #' -#' #' @description `r lifecycle::badge("experimental")` #' #' We provide additional utility functions to allow human-friendly rendition of