From b4154bf2b72205a58455a51d98b932f79a14be0c Mon Sep 17 00:00:00 2001 From: "CINO (Christian Haargaard Olsen)" Date: Fri, 17 Apr 2026 10:40:29 +0200 Subject: [PATCH 1/4] Fix DESCRIPTION and add NEWS.md for CRAN submission MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove Remotes block (chef and chefStats submitted simultaneously) - Bump version from 0.0.1.9000 to 0.1.0 - Title case: "A Collection of 'chef' Criterion Functions" - Expand Description to 3 sentences - Add BugReports field - Remove unused Imports (magrittr, purrr, dplyr, knitr) — none are referenced in NAMESPACE or active R code - Move knitr to Suggests (only needed as VignetteBuilder) - Tidy URL field, remove codecov URL - Create NEWS.md with initial release entry Co-Authored-By: Claude Sonnet 4.6 --- DESCRIPTION | 37 ++++++++++++++++++------------------- NEWS.md | 5 +++++ 2 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 NEWS.md diff --git a/DESCRIPTION b/DESCRIPTION index fcefd43..a50c478 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,33 +1,32 @@ Package: chefCriteria -Title: A collection of {chef} criterion functions -Version: 0.0.1.9000 -Authors@R: +Title: A Collection of 'chef' Criterion Functions +Version: 0.1.0 +Authors@R: c(person("MEWP (Matthew David Phelps)", , , "mewp@novonordisk.com", role = c("aut")), person("NOSJ (Nicolai Skov Johnsen)",, , "nosj@novonordisk.com", role = c("aut")), person("HSPU (Henrik Sparre Spiegelhauer)",, , "hspu@novonordisk.com", role = c("aut")), person("CINO (Christian Haargaard Olsen)",, , "cino@novonordisk.com", role = c("aut", "cre"))) -Description: A collection of criterion functions for statistical evidence generation with {chef}. +Description: Provides a collection of criterion functions for use with the 'chef' + pipeline framework for clinical trial evidence generation. Criterion functions + determine whether a statistical analysis should be included in the final output + based on conditions such as minimum subject counts or p-value thresholds. + Designed for use in healthcare technology assessments such as AMNOG dossier + submissions. License: MIT + file LICENSE +BugReports: https://github.com/hta-pharma/chefCriteria/issues Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Config/testthat/edition: 3 -Imports: +Imports: chef, chefStats, - data.table (>= 1.14.2), - magrittr, - purrr, - dplyr, - knitr -Suggests: + data.table (>= 1.14.2) +Suggests: testthat (>= 3.0.0), - pharmaverseadam -Remotes: - hta-pharma/chefStats, - hta-pharma/chef -VignetteBuilder: + pharmaverseadam, + knitr +VignetteBuilder: knitr -URL: - https://hta-pharma.github.io/chefCriteria/, - https://app.codecov.io/gh/hta-pharma/chefCriteria +URL: https://hta-pharma.github.io/chefCriteria/, + https://github.com/hta-pharma/chefCriteria diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..54c76bb --- /dev/null +++ b/NEWS.md @@ -0,0 +1,5 @@ +# chefCriteria 0.1.0 + +* Initial CRAN submission. +* Provides `crit_bb_nsubev_01()`, `crit_bb_pval_01()`, and `crit_ep_nsubev_01()` + as inclusion criterion functions for use with the `chef` pipeline framework. From a7636a74830338ea2473ff340a2ed6b3fa0ddf8e Mon Sep 17 00:00:00 2001 From: "CINO (Christian Haargaard Olsen)" Date: Fri, 17 Apr 2026 10:46:10 +0200 Subject: [PATCH 2/4] Add examples to all 3 exported functions Co-Authored-By: Claude Sonnet 4.6 --- R/crit_by_strata_by_trt.R | 21 +++++++++++++++++++++ R/crit_endpoint.R | 11 +++++++++++ man/crit_bb_nsubev_01.Rd | 11 +++++++++++ man/crit_bb_pval_01.Rd | 12 ++++++++++++ man/crit_ep_nsubev_01.Rd | 12 ++++++++++++ 5 files changed, 67 insertions(+) diff --git a/R/crit_by_strata_by_trt.R b/R/crit_by_strata_by_trt.R index 04c58bd..e11112f 100644 --- a/R/crit_by_strata_by_trt.R +++ b/R/crit_by_strata_by_trt.R @@ -14,6 +14,16 @@ #' @return A Boolean value indicating whether the criterion is met. #' @export #' @import data.table +#' @examples +#' dat <- data.table::data.table(USUBJID = c("S1", "S2", "S3", "S4")) +#' dat[, INDEX_ := .I] +#' data.table::setkey(dat, INDEX_) +#' # Returns TRUE: 2 subjects with events >= minimum of 2 +#' crit_bb_nsubev_01(dat, event_index = c(1L, 2L), +#' subjectid_var = "USUBJID", n_subj_event_min = 2L) +#' # Returns FALSE: 1 subject with events < minimum of 2 +#' crit_bb_nsubev_01(dat, event_index = c(1L), +#' subjectid_var = "USUBJID", n_subj_event_min = 2L) crit_bb_nsubev_01 <- function(dat, event_index, subjectid_var, n_subj_event_min, ...){ # Evaluate criterion @@ -45,6 +55,17 @@ crit_bb_nsubev_01 <- function(dat, event_index, subjectid_var, n_subj_event_min, #' #' @return A Boolean value indicating whether the criterion is met. #' @export +#' @examples +#' dat <- data.table::data.table( +#' USUBJID = c("S1", "S2", "S3", "S4", "S5", "S6"), +#' TRT = c("Active", "Active", "Active", "Placebo", "Placebo", "Placebo") +#' ) +#' dat[, INDEX_ := .I] +#' data.table::setkey(dat, INDEX_) +#' crit_bb_pval_01(dat, event_index = c(1L, 2L, 4L), +#' cell_index = dat[["INDEX_"]], +#' treatment_var = "TRT", treatment_refval = "Placebo", +#' subjectid_var = "USUBJID", pval_max = 0.05) crit_bb_pval_01 <- function(dat, event_index, diff --git a/R/crit_endpoint.R b/R/crit_endpoint.R index 19dd86d..57e0e89 100644 --- a/R/crit_endpoint.R +++ b/R/crit_endpoint.R @@ -15,6 +15,17 @@ #' @return A Boolean value indicating whether the criterion is met. #' @import data.table #' @export +#' @examples +#' dat <- data.table::data.table( +#' USUBJID = c("S1", "S2", "S3", "S4"), +#' TRT = c("Active", "Active", "Placebo", "Placebo") +#' ) +#' dat[, INDEX_ := .I] +#' data.table::setkey(dat, INDEX_) +#' # Returns TRUE: Active arm has 2 subjects with events >= minimum of 2 +#' crit_ep_nsubev_01(dat, event_index = c(1L, 2L), +#' subjectid_var = "USUBJID", +#' treatment_var = "TRT", n_subj_event_min = 2L) crit_ep_nsubev_01 <- function(dat, event_index, subjectid_var, diff --git a/man/crit_bb_nsubev_01.Rd b/man/crit_bb_nsubev_01.Rd index 2d84de6..2fde18f 100644 --- a/man/crit_bb_nsubev_01.Rd +++ b/man/crit_bb_nsubev_01.Rd @@ -25,3 +25,14 @@ A Boolean value indicating whether the criterion is met. \description{ This function checks if the number of subjects with events in the total population is greater than or equal to a specified minimum. } +\examples{ +dat <- data.table::data.table(USUBJID = c("S1", "S2", "S3", "S4")) +dat[, INDEX_ := .I] +data.table::setkey(dat, INDEX_) +# Returns TRUE: 2 subjects with events >= minimum of 2 +crit_bb_nsubev_01(dat, event_index = c(1L, 2L), + subjectid_var = "USUBJID", n_subj_event_min = 2L) +# Returns FALSE: 1 subject with events < minimum of 2 +crit_bb_nsubev_01(dat, event_index = c(1L), + subjectid_var = "USUBJID", n_subj_event_min = 2L) +} diff --git a/man/crit_bb_pval_01.Rd b/man/crit_bb_pval_01.Rd index 3aabe9e..d4830cb 100644 --- a/man/crit_bb_pval_01.Rd +++ b/man/crit_bb_pval_01.Rd @@ -43,3 +43,15 @@ A Boolean value indicating whether the criterion is met. \description{ This function checks if the p-value in the total population is below a specified maximum. } +\examples{ +dat <- data.table::data.table( + USUBJID = c("S1", "S2", "S3", "S4", "S5", "S6"), + TRT = c("Active", "Active", "Active", "Placebo", "Placebo", "Placebo") +) +dat[, INDEX_ := .I] +data.table::setkey(dat, INDEX_) +crit_bb_pval_01(dat, event_index = c(1L, 2L, 4L), + cell_index = dat[["INDEX_"]], + treatment_var = "TRT", treatment_refval = "Placebo", + subjectid_var = "USUBJID", pval_max = 0.05) +} diff --git a/man/crit_ep_nsubev_01.Rd b/man/crit_ep_nsubev_01.Rd index 38156d9..7985793 100644 --- a/man/crit_ep_nsubev_01.Rd +++ b/man/crit_ep_nsubev_01.Rd @@ -34,3 +34,15 @@ A Boolean value indicating whether the criterion is met. \description{ This function checks if the number of subjects with events in at least one study arm is greater than or equal to a specified minimum. } +\examples{ +dat <- data.table::data.table( + USUBJID = c("S1", "S2", "S3", "S4"), + TRT = c("Active", "Active", "Placebo", "Placebo") +) +dat[, INDEX_ := .I] +data.table::setkey(dat, INDEX_) +# Returns TRUE: Active arm has 2 subjects with events >= minimum of 2 +crit_ep_nsubev_01(dat, event_index = c(1L, 2L), + subjectid_var = "USUBJID", + treatment_var = "TRT", n_subj_event_min = 2L) +} From 577d72313f5f969a2b3bf07d3144eb87f0ab43a8 Mon Sep 17 00:00:00 2001 From: "CINO (Christian Haargaard Olsen)" Date: Fri, 17 Apr 2026 14:07:31 +0200 Subject: [PATCH 3/4] Fix R CMD check issues for CRAN submission - Remove VignetteBuilder/knitr (no vignettes exist) - Move chef from Imports to Suggests (only used in tests, not in R code) - Add dplyr and purrr to Suggests (used in test helpers) - Add .pre-commit-config.yaml, .githooks, README.rmd, cran-plan.md to .Rbuildignore to suppress non-standard top-level file NOTEs - Fix {ramnog} -> \pkg{ramnog} in crit_by_strata_by_trt.R and crit_bb_pval_01.Rd Co-Authored-By: Claude Sonnet 4.6 --- .Rbuildignore | 3 +++ DESCRIPTION | 7 +++---- R/crit_by_strata_by_trt.R | 2 +- man/crit_bb_pval_01.Rd | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 4499be5..90cf0da 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,6 @@ README.html ^docs$ ^pkgdown$ ^\.github$ +^\.pre-commit-config\.yaml$ +^\.githooks$ +^README\.rmd$ diff --git a/DESCRIPTION b/DESCRIPTION index a50c478..20af7d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,14 +19,13 @@ Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Config/testthat/edition: 3 Imports: - chef, chefStats, data.table (>= 1.14.2) Suggests: + chef, testthat (>= 3.0.0), pharmaverseadam, - knitr -VignetteBuilder: - knitr + dplyr, + purrr URL: https://hta-pharma.github.io/chefCriteria/, https://github.com/hta-pharma/chefCriteria diff --git a/R/crit_by_strata_by_trt.R b/R/crit_by_strata_by_trt.R index e11112f..b59f35f 100644 --- a/R/crit_by_strata_by_trt.R +++ b/R/crit_by_strata_by_trt.R @@ -45,7 +45,7 @@ crit_bb_nsubev_01 <- function(dat, event_index, subjectid_var, n_subj_event_min, #' `dat`. #' @param cell_index A vector of integers referencing the rows of `dat` (as #' specified by the `INDEX_` column in `dat`) that match the population to be -#' analyzed. See the "Endpoint Events" vignette in {ramnog} +#' analyzed. See the "Endpoint Events" vignette in \pkg{ramnog} #' for more information. #' @param treatment_var character. The name of the treatment variable in `dat`. #' @param treatment_refval character. The reference value of the treatment variable in `dat`. diff --git a/man/crit_bb_pval_01.Rd b/man/crit_bb_pval_01.Rd index d4830cb..6d33ba1 100644 --- a/man/crit_bb_pval_01.Rd +++ b/man/crit_bb_pval_01.Rd @@ -24,7 +24,7 @@ the definition of an 'event'. Matching is done via the \code{INDEX_} column in \item{cell_index}{A vector of integers referencing the rows of \code{dat} (as specified by the \code{INDEX_} column in \code{dat}) that match the population to be -analyzed. See the "Endpoint Events" vignette in {ramnog} +analyzed. See the "Endpoint Events" vignette in \pkg{ramnog} for more information.} \item{treatment_var}{character. The name of the treatment variable in \code{dat}.} From 556d6dbc0ac499797a694f29f342dddc4015c986 Mon Sep 17 00:00:00 2001 From: "CINO (Christian Haargaard Olsen)" Date: Wed, 27 May 2026 22:52:08 +0200 Subject: [PATCH 4/4] Add Remotes: chef + chefStats and tools/strip-remotes.R helper for CRAN submission Adds Remotes: hta-pharma/chef@feature/CRAN_submission and hta-pharma/chefStats@feature/CRAN_submission so GitHub Actions can resolve those dependencies from GitHub during CI (neither is on CRAN yet). CRAN forbids Remotes: in submitted tarballs, so tools/strip-remotes.R removes the field before R CMD build. The helper restores DESCRIPTION afterwards when invoked with --build, leaving the working tree unchanged. Both tools/ and cran-plan.md are ignored at build time. Co-Authored-By: Claude Opus 4.7 --- .Rbuildignore | 2 ++ DESCRIPTION | 3 ++ tools/strip-remotes.R | 68 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 tools/strip-remotes.R diff --git a/.Rbuildignore b/.Rbuildignore index 90cf0da..e246955 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -9,3 +9,5 @@ README.html ^\.pre-commit-config\.yaml$ ^\.githooks$ ^README\.rmd$ +^tools$ +^cran-plan\.md$ diff --git a/DESCRIPTION b/DESCRIPTION index 20af7d5..f074586 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,6 +18,9 @@ Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.1 Config/testthat/edition: 3 +Remotes: + hta-pharma/chef@feature/CRAN_submission, + hta-pharma/chefStats@feature/CRAN_submission Imports: chefStats, data.table (>= 1.14.2) diff --git a/tools/strip-remotes.R b/tools/strip-remotes.R new file mode 100644 index 0000000..9b512f9 --- /dev/null +++ b/tools/strip-remotes.R @@ -0,0 +1,68 @@ +#!/usr/bin/env Rscript +# Strip the `Remotes:` block from DESCRIPTION before building a CRAN tarball. +# +# Remotes is used during CI/development so dependent packages can pull +# unreleased versions of sibling packages from GitHub. CRAN rejects any +# package whose DESCRIPTION contains a Remotes field, so it must be removed +# from the tarball that is submitted. +# +# Usage (from the package root): +# Rscript tools/strip-remotes.R # rewrites DESCRIPTION in place +# Rscript tools/strip-remotes.R --build # also runs R CMD build on the cleaned source +# +# The --build flag produces _.tar.gz in the parent directory +# (R CMD build's default), then restores DESCRIPTION so the working tree +# is left as it was. + +args <- commandArgs(trailingOnly = TRUE) +do_build <- "--build" %in% args + +desc_path <- "DESCRIPTION" +if (!file.exists(desc_path)) { + stop("DESCRIPTION not found. Run this script from the package root.") +} + +original <- readLines(desc_path, warn = FALSE) + +# A DESCRIPTION field starts at column 1; continuation lines are indented. +# Drop the line matching `^Remotes:` and any continuation lines that follow. +field_start <- grepl("^[^[:space:]]", original) +remotes_idx <- which(grepl("^Remotes:", original)) + +if (length(remotes_idx) == 0) { + message("No Remotes: field found in DESCRIPTION; nothing to strip.") + cleaned <- original +} else { + drop <- integer() + for (i in remotes_idx) { + drop <- c(drop, i) + j <- i + 1L + while (j <= length(original) && !field_start[j]) { + drop <- c(drop, j) + j <- j + 1L + } + } + cleaned <- original[-drop] + message("Stripped Remotes block (", length(drop), " line(s)).") +} + +if (do_build) { + # Snapshot the original so we can restore it after R CMD build. + backup <- tempfile("DESCRIPTION-") + file.copy(desc_path, backup, overwrite = TRUE) + on.exit({ + file.copy(backup, desc_path, overwrite = TRUE) + unlink(backup) + message("Restored original DESCRIPTION.") + }, add = TRUE) + + writeLines(cleaned, desc_path) + status <- system2("R", c("CMD", "build", ".")) + if (status != 0) { + stop("R CMD build failed (exit ", status, ").") + } +} else { + writeLines(cleaned, desc_path) + message("DESCRIPTION rewritten in place. Re-run with --build to produce a tarball,", + " or restore from git when done submitting.") +}