Skip to content

Commit

Permalink
delete coverage part
Browse files Browse the repository at this point in the history
  • Loading branch information
gravesti committed Sep 27, 2024
1 parent 647f040 commit a850f0f
Showing 1 changed file with 0 additions and 70 deletions.
70 changes: 0 additions & 70 deletions vignettes/knit_print.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit a850f0f

Please sign in to comment.