Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ README.html
^docs$
^pkgdown$
^\.github$
^\.pre-commit-config\.yaml$
^\.githooks$
^README\.rmd$
^tools$
^cran-plan\.md$
43 changes: 22 additions & 21 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
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:
chef,
Remotes:
hta-pharma/chef@feature/CRAN_submission,
hta-pharma/chefStats@feature/CRAN_submission
Imports:
chefStats,
data.table (>= 1.14.2),
magrittr,
purrr,
dplyr,
knitr
Suggests:
data.table (>= 1.14.2)
Suggests:
chef,
testthat (>= 3.0.0),
pharmaverseadam
Remotes:
hta-pharma/chefStats,
hta-pharma/chef
VignetteBuilder:
knitr
URL:
https://hta-pharma.github.io/chefCriteria/,
https://app.codecov.io/gh/hta-pharma/chefCriteria
pharmaverseadam,
dplyr,
purrr
URL: https://hta-pharma.github.io/chefCriteria/,
https://github.com/hta-pharma/chefCriteria
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
23 changes: 22 additions & 1 deletion R/crit_by_strata_by_trt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,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`.
Expand All @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions R/crit_endpoint.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 11 additions & 0 deletions man/crit_bb_nsubev_01.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion man/crit_bb_pval_01.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions man/crit_ep_nsubev_01.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 68 additions & 0 deletions tools/strip-remotes.R
Original file line number Diff line number Diff line change
@@ -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 <pkg>_<version>.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.")
}
Loading