Skip to content

Commit

Permalink
Issues 19 and 21 fixed
Browse files Browse the repository at this point in the history
+ codecov added
+ Issues [#19](#19) and [#21](#21) fixed
  • Loading branch information
fpahlke committed Feb 22, 2024
1 parent 8344d89 commit 404472f
Show file tree
Hide file tree
Showing 94 changed files with 10,528 additions and 9,997 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ testthat-problems\.rds
^.*\.gcno$
^inst/\.covrignore$
^README\.html$
^codecov\.yml$
57 changes: 57 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: test-coverage

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage

- name: Test coverage
run: |
Sys.setenv("RPACT_COMPLETE_UNIT_TEST_SET_ENABLED" = TRUE)
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: rpact-com/rpact
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: rpact
Title: Confirmatory Adaptive Clinical Trial Design and Analysis
Version: 3.5.1.9231
Date: 2024-02-09
Version: 3.5.1
Date: 2024-02-16
Authors@R: c(
person(
given = "Gernot",
Expand Down
15 changes: 14 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
# rpact 3.5.1

* The fields `.parameterNames` and `.parameterFormatFunctions` were removed from all rpact result objects in favor of a more efficient solution
* Issues [15](https://github.com/rpact-com/rpact/issues/15), [16](https://github.com/rpact-com/rpact/issues/16), and [17](https://github.com/rpact-com/rpact/issues/17) fixed
* Issues [#15](https://github.com/rpact-com/rpact/issues/15), [#16](https://github.com/rpact-com/rpact/issues/16), [#17](https://github.com/rpact-com/rpact/issues/17), and [#19](https://github.com/rpact-com/rpact/issues/19) fixed
* Fixed inconsistent naming of variables and class fields (issue [#21](https://github.com/rpact-com/rpact/issues/21))
- `getSampleSizeSurvival()` / `getPowerSurvival()`:
+ Field `eventsPerStage` replaced by `cumulativeEventsPerStage`
+ Field `singleEventsPerStage` added
- `getSimulationSurvival()`:
+ Field `eventsPerStage` replaced by `singleEventsPerStage`
+ Field `overallEventsPerStage` replaced by `cumulativeEventsPerStage`
- `getSimulationMultiArmSurvival()`:
+ Field `eventsPerStage` replaced by `cumulativeEventsPerStage`
+ Field `singleNumberOfEventsPerStage` replaced by `singleEventsPerArmAndStage`
+ Field `singleEventsPerStage` added
- `getSimulationEnrichmentSurvival()`:
+ field `singleNumberOfEventsPerStage` replaced by `singleEventsPerPopulationAndStage`


# rpact 3.5.0
Expand Down
28 changes: 14 additions & 14 deletions R/class_analysis_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
## | File version: $Revision: 7620 $
## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | File version: $Revision: 7645 $
## | Last changed: $Date: 2024-02-16 16:12:34 +0100 (Fr, 16 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |

Expand Down Expand Up @@ -615,19 +615,19 @@ writeDatasets <- function(datasets, file, ..., append = FALSE, quote = TRUE, sep
#'
#' For enrichment designs, the comparison of two samples is provided for an unstratified
#' (sub-population wise) or stratified data input.\cr
#' For unstratified (sub-population wise) data input the data sets are defined for the sub-populations
#' For non-stratified (sub-population wise) data input the data sets are defined for the sub-populations
#' S1, S2, ..., F, where F refers to the full populations. Use of \code{getDataset(S1 = , S2, ..., F = )}
#' defines the data set to be used in \code{\link[=getAnalysisResults]{getAnalysisResults()}} (see examples)\cr
#' For stratified data input the data sets are defined for the strata S1, S12, S2, ..., R, where R
#' refers to the remainder of the strata such that the union of all sets is the full population.
#' Use of \code{getDataset(S1 = , S12 = , S2, ..., R = )} defines the data set to be used in
#' \code{\link[=getAnalysisResults]{getAnalysisResults()}} (see examples)\cr
#' For survival data, for enrichment designs the log-rank statistics should be entered as stratified
#' For survival data, for enrichment designs the log-rank statistics can only be entered as stratified
#' log-rank statistics in order to provide strong control of Type I error rate. For stratified data input,
#' the variables to be specified in \code{getDataset()} are \code{events}, \code{expectedEvents},
#' \code{varianceEvents}, and \code{allocationRatios} or \code{overallEvents}, \code{overallExpectedEvents},
#' \code{overallVarianceEvents}, and \code{overallAllocationRatios}. From this, (stratified) log-rank tests are
#' calculated.
#' the variables to be specified in \code{getDataset()} are \code{cumEvents}, \code{cumExpectedEvents},
#' \code{cumVarianceEvents}, and \code{cumAllocationRatios} or \code{overallEvents}, \code{overallExpectedEvents},
#' \code{overallVarianceEvents}, and \code{overallAllocationRatios}. From this, (stratified) log-rank tests and
#' and the independent increments are calculated.
#'
#' @template return_object_dataset
#'
Expand Down Expand Up @@ -1463,7 +1463,7 @@ Dataset <- setRefClass("Dataset",

if (any(grepl("^subsets?\\d*$", colnames(dataFrame)))) {
numberOfTreatmentGroups <- .getNumberOfGroups(dataFrame, c(C_KEY_WORDS_SAMPLE_SIZES, C_KEY_WORDS_LOG_RANKS))
subsets <<- character(0)
subsets <<- character()
for (group in 1:numberOfTreatmentGroups) {
suffix <- ifelse(any(grepl("^subsets?\\d+$", colnames(dataFrame))), group, "")
subsets <<- c(subsets, .getValuesByParameterName(dataFrame, C_KEY_WORDS_SUBSETS, suffix = suffix))
Expand Down Expand Up @@ -1729,7 +1729,7 @@ Dataset <- setRefClass("Dataset",
getNumberOfStages = function(naOmitEnabled = TRUE) {
if (naOmitEnabled) {
colNames <- colnames(.data)
validColNames <- character(0)
validColNames <- character()
for (colName in colNames) {
colValues <- .data[, colName]
if (length(colValues) > 0 && !all(is.na(colValues))) {
Expand Down Expand Up @@ -3755,10 +3755,10 @@ DatasetEnrichmentSurvival <- setRefClass("DatasetEnrichmentSurvival",
if (.paramExists(dataFrame, C_KEY_WORDS_OVERALL_EXPECTED_EVENTS) ||
.paramExists(dataFrame, C_KEY_WORDS_OVERALL_VARIANCE_EVENTS)) {
if (!.paramExists(dataFrame, C_KEY_WORDS_OVERALL_EXPECTED_EVENTS)) {
stop(C_EXCEPTION_TYPE_MISSING_ARGUMENT, "'overallExpectedEvents' is missing")
stop(C_EXCEPTION_TYPE_MISSING_ARGUMENT, "'overallExpectedEvents' or 'cumExpectedEvents' is missing")
}
if (!.paramExists(dataFrame, C_KEY_WORDS_OVERALL_VARIANCE_EVENTS)) {
stop(C_EXCEPTION_TYPE_MISSING_ARGUMENT, "'overallVarianceEvents' is missing")
stop(C_EXCEPTION_TYPE_MISSING_ARGUMENT, "'overallVarianceEvents' or 'cumVarianceEvents' is missing")
}

.inputType <<- "overall"
Expand Down Expand Up @@ -4012,7 +4012,7 @@ summary.Dataset <- function(object, ..., type = 1, digits = NA_integer_) {
digitsGeneral <- digitSettings$digitsGeneral
digitsProbabilities <- digitSettings$digitsProbabilities

paramsToCheck <- character(0)
paramsToCheck <- character()
if (object$isDatasetMeans() || object$isDatasetRates()) {
paramsToCheck <- c(paramsToCheck, "sampleSizes")
if (kMax > 1) {
Expand Down Expand Up @@ -4143,7 +4143,7 @@ summary.Dataset <- function(object, ..., type = 1, digits = NA_integer_) {

.getDatasetArgumentsRCodeLines <- function(x, complete = FALSE, digits = 4) {
m <- getWideFormat(x)
lines <- character(0)
lines <- character()
paramNames <- colnames(m)
if (!complete) {
if (x$.inputType == "stagewise") {
Expand Down
8 changes: 4 additions & 4 deletions R/class_analysis_stage_results.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
## | File version: $Revision: 7620 $
## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | File version: $Revision: 7645 $
## | Last changed: $Date: 2024-02-16 16:12:34 +0100 (Fr, 16 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |

Expand Down Expand Up @@ -1437,7 +1437,7 @@ plot.StageResults <- function(x, y, ..., type = 1L,
data <- data.frame(
xValues = numeric(0),
yValues = numeric(0),
categories = character(0),
categories = character(),
treatmentArms = numeric(0)
)
for (treatmentArm in treatmentArmsToShow) {
Expand Down Expand Up @@ -1486,7 +1486,7 @@ plot.StageResults <- function(x, y, ..., type = 1L,
data <- data.frame(
xValues = numeric(0),
yValues = numeric(0),
categories = character(0),
categories = character(),
populations = numeric(0)
)
for (population in populationsToShow) {
Expand Down
25 changes: 14 additions & 11 deletions R/class_core_parameter_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
## | File version: $Revision: 7620 $
## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | File version: $Revision: 7650 $
## | Last changed: $Date: 2024-02-20 14:37:26 +0100 (Di, 20 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |

Expand Down Expand Up @@ -45,7 +45,8 @@ FieldSet <- setRefClass("FieldSet",
fields = list(
.parameterTypes = "list",
.showParameterTypeEnabled = "logical",
.catLines = "character"
.catLines = "character",
.deprecatedFieldNames = "character"
),
methods = list(
.getFieldNames = function() {
Expand All @@ -54,10 +55,11 @@ FieldSet <- setRefClass("FieldSet",
.getVisibleFieldNames = function() {
fieldNames <- names(.self$getRefClass()$fields())
fieldNames <- fieldNames[!startsWith(fieldNames, ".")]
fieldNames <- fieldNames[!(fieldNames %in% .deprecatedFieldNames)]
return(fieldNames)
},
.resetCat = function() {
.catLines <<- character(0)
.catLines <<- character()
},
.cat = function(..., file = "", sep = "", fill = FALSE, labels = NULL,
append = FALSE, heading = 0, tableColumns = 0, consoleOutputEnabled = TRUE,
Expand Down Expand Up @@ -199,7 +201,8 @@ ParameterSet <- setRefClass("ParameterSet",
.showParameterTypeEnabled = .showParameterTypeEnabled
)
.parameterTypes <<- list()
.catLines <<- character(0)
.catLines <<- character()
.deprecatedFieldNames <<- character()
},
clone = function() {
paramNames <- names(.self$getRefClass()$fields())
Expand Down Expand Up @@ -605,7 +608,7 @@ ParameterSet <- setRefClass("ParameterSet",
paramCaption <- paste0("%", paramName, "%")
}
if (!is.null(category) && !is.na(category)) {
if (.isMultiArmSimulationResults(.self) && paramName == "singleNumberOfEventsPerStage") {
if (.isMultiArmSimulationResults(.self) && paramName == "singleEventsPerArmAndStage") {
if (!inherits(.self, "SimulationResultsEnrichmentSurvival") &&
!is.na(numberOfCategories) && numberOfCategories == category) {
category <- "control"
Expand Down Expand Up @@ -1112,7 +1115,7 @@ ParameterSet <- setRefClass("ParameterSet",
names(dataFrame) <- stagesCaption

if (parameterSet$.isEnrichmentObject()) {
populations <- character(0)
populations <- character()
for (i in 1:numberOfVariants) {
populations <- c(populations, ifelse(i == numberOfVariants, "F", paste0("S", i)))
}
Expand All @@ -1139,7 +1142,7 @@ ParameterSet <- setRefClass("ParameterSet",
}
)

usedParameterNames <- character(0)
usedParameterNames <- character()
for (parameterName in parameterNames) {
tryCatch(
{
Expand Down Expand Up @@ -1284,7 +1287,7 @@ ParameterSet <- setRefClass("ParameterSet",
includeAllParameters = FALSE,
handleParameterNamesAsToBeExcluded = FALSE,
returnParametersAsCharacter = FALSE,
mandatoryParameterNames = character(0)) {
mandatoryParameterNames = character()) {
parameterNamesToBeExcluded <- c()
if (handleParameterNamesAsToBeExcluded) {
parameterNamesToBeExcluded <- parameterNames
Expand All @@ -1297,7 +1300,7 @@ ParameterSet <- setRefClass("ParameterSet",
}
parameterNames <- parameterNames[!grepl("^\\.", parameterNames)]

parametersToIgnore <- character(0)
parametersToIgnore <- character()
if (!is.null(parameterSet[[".piecewiseSurvivalTime"]]) &&
parameterSet$.piecewiseSurvivalTime$piecewiseSurvivalEnabled) {
parametersToIgnore <- c(
Expand Down Expand Up @@ -1354,7 +1357,7 @@ ParameterSet <- setRefClass("ParameterSet",

.getCategoryCaptionEnrichment <- function(parameterSet, parameterName, categoryNumber) {
categoryCaption <- categoryNumber
if (parameterName %in% c("sampleSizes", "singleNumberOfEventsPerStage")) {
if (parameterName %in% c("sampleSizes", "singleEventsPerPopulationAndStage")) {
categoryCaption <- parameterSet$effectList$subGroups[categoryNumber]
maxNumberOfDigits <- max(nchar(sub("\\D*", "", parameterSet$effectList$subGroups)))
if (parameterSet$populations > 2 && grepl(paste0("^S\\d{1,", maxNumberOfDigits - 1, "}$"), categoryCaption)) {
Expand Down
6 changes: 3 additions & 3 deletions R/class_core_plot_settings.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
## | File version: $Revision: 7620 $
## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | File version: $Revision: 7645 $
## | Last changed: $Date: 2024-02-16 16:12:34 +0100 (Fr, 16 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |

Expand Down Expand Up @@ -103,7 +103,7 @@ PlotSubTitleItems <- setRefClass("PlotSubTitleItems",
return(NA_character_)
}

s <- character(0)
s <- character()
for (item in items) {
s <- c(s, item$toString())
}
Expand Down
14 changes: 10 additions & 4 deletions R/class_design_plan.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
## |
## | Contact us for information about our services: info@rpact.com
## |
## | File version: $Revision: 7620 $
## | Last changed: $Date: 2024-02-09 12:57:37 +0100 (Fr, 09 Feb 2024) $
## | File version: $Revision: 7651 $
## | Last changed: $Date: 2024-02-20 15:45:44 +0100 (Di, 20 Feb 2024) $
## | Last changed by: $Author: pahlke $
## |

Expand Down Expand Up @@ -699,6 +699,8 @@ TrialDesignPlanRates <- setRefClass("TrialDesignPlanRates",
#' @template field_studyDuration
#' @template field_maxStudyDuration
#' @template field_eventsPerStage
#' @template field_singleEventsPerStage
#' @template field_cumulativeEventsPerStage
#' @template field_expectedEventsH0
#' @template field_expectedEventsH01
#' @template field_expectedEventsH1
Expand All @@ -715,7 +717,7 @@ TrialDesignPlanRates <- setRefClass("TrialDesignPlanRates",
#' @template field_futilityBoundsEffectScaleLower
#' @template field_futilityBoundsEffectScaleUpper
#' @template field_futilityBoundsPValueScale
#'
#'
#' @details
#' This object cannot be created directly; use \code{\link[=getSampleSizeSurvival]{getSampleSizeSurvival()}}
#' with suitable arguments to create a design plan for a dataset of survival data.
Expand Down Expand Up @@ -783,7 +785,9 @@ TrialDesignPlanSurvival <- setRefClass("TrialDesignPlanSurvival",
studyDurationH1 = "numeric",
studyDuration = "numeric",
maxStudyDuration = "numeric",
eventsPerStage = "matrix",
eventsPerStage = "matrix", # deprecated
singleEventsPerStage = "matrix",
cumulativeEventsPerStage = "matrix",
expectedEventsH0 = "numeric",
expectedEventsH01 = "numeric",
expectedEventsH1 = "numeric",
Expand Down Expand Up @@ -826,6 +830,8 @@ TrialDesignPlanSurvival <- setRefClass("TrialDesignPlanSurvival",
.setParameterType("futilityBoundsEffectScale", C_PARAM_NOT_APPLICABLE)
.setParameterType("futilityBoundsEffectScaleLower", C_PARAM_NOT_APPLICABLE)
.setParameterType("futilityBoundsEffectScaleUpper", C_PARAM_NOT_APPLICABLE)

.setParameterType("singleEventsPerStage", C_PARAM_NOT_APPLICABLE)

# set default values
for (parameterName in c(
Expand Down

0 comments on commit 404472f

Please sign in to comment.