From a850f0f1b2f31c2040869daa8d0b269cfc77b449 Mon Sep 17 00:00:00 2001 From: Isaac Gravestock Date: Fri, 27 Sep 2024 10:39:42 +0200 Subject: [PATCH] delete coverage part --- vignettes/knit_print.qmd | 70 ---------------------------------------- 1 file changed, 70 deletions(-) diff --git a/vignettes/knit_print.qmd b/vignettes/knit_print.qmd index d3be4b9cb..0b8c9de47 100644 --- a/vignettes/knit_print.qmd +++ b/vignettes/knit_print.qmd @@ -321,73 +321,3 @@ registerS3method("knit_print", "NextBestNCRM", knit_print.NextBestNCRM) .DefaultNextBestNCRM() ``` -## Class coverage - -```{r} -#| label: coverage-1 -#| echo: FALSE -#| eval: FALSE -crmpackClasses <- getClasses(asNamespace("crmPack")) - -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")) -} - -df <- lapply( - crmpackClasses, - function(cls) { - tryCatch( - { - x <- do.call(paste0(".Default", cls), list()) - method <- h_custom_method_exists(knit_print, x) - tibble(Class = cls, Constructor = "OK", KnitPrint = method) - }, - error = function(e) { - tibble(Class = cls, Constructor = geterrmessage(), KnitPrint = FALSE) - } - ) - } -) %>% bind_rows() -allClasses <- df %>% nrow() -knitPrintDefined <- df %>% - filter(KnitPrint) %>% - nrow() -knitPrintNotDefined <- allClasses - knitPrintDefined -virtualClasses <- df %>% - filter(Constructor != "OK") %>% - nrow() -stillToDo <- df %>% - filter(Constructor == "OK", !KnitPrint) %>% - nrow() -``` -```{r} -allClasses <- knitPrintDefined <- knitPrintNotDefined <- virtualClasses <- stillToDo <- 0 -``` - -`crmPack` defines `r allClasses` classes. Custom `knit_print` methods exist for `r knitPrintDefined` -of them. Of the remaining `r knitPrintNotDefined` classes, `r virtualClasses` are virtual classes -that will never be directly instantiated by end users. That leaves `r stillToDo` classes for which -`knit_print` methods may be useful. These classes are listed below. - -```{r} -#| label: coverage-2 -#| echo: FALSE -#| eval: FALSE - -df %>% - filter(Constructor == "OK", !KnitPrint) %>% - select(Class) %>% - kable() -``` - -The majority of these classes relate to simulation of the operating characteristics of CRM trials. -Reporting of this information is likely to need customisation that is beyond the scope of a simple -function[^4]. - -[^4]: The `crmPack` team is considering the creation of markdown or Quarto templates that may assist - in this area, but consider this to be a long-term ambition.