Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include column "Bound" in summary.gs_design() output #422

Merged
merged 1 commit into from
Jun 20, 2024
Merged
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gsDesign2
Title: Group Sequential Design with Non-Constant Effect
Version: 1.1.2.11
Version: 1.1.2.12
Authors@R: c(
person("Keaven", "Anderson", email = "[email protected]", role = c("aut")),
person("Yilong", "Zhang", email = "[email protected]", role = c("aut")),
Expand Down
8 changes: 8 additions & 0 deletions R/summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ summary.gs_design <- function(object,
}
}

# "bound" is a required column
if (!"bound" %in% x_decimals$col_vars) {
x_decimals <- rbind(
tibble::tibble(col_vars = "bound", col_decimals = NA),
x_decimals
)
}

# Prepare the analysis summary row ----
# get the
# (1) analysis variables to be displayed on the header
Expand Down
28 changes: 28 additions & 0 deletions tests/testthat/test-developer-summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,31 @@ test_that("summary.gs_design() accepts a named vector for analysis_decimals", {
"summary: analysis_decimals must be a named vector if analysis_vars is not provided"
)
})

test_that("The column 'Bound' is always included in summary.gs_design() output", {
x <- gs_design_ahr()

# without col_vars
observed <- summary(x)
expect_true("Bound" %in% colnames(observed))

# including "bound" in col_vars
observed <- summary(
x,
col_vars = c(
"bound", "z", "~hr at bound", "nominal p", "Alternate hypothesis", "Null hypothesis"
),
col_decimals = c(NA, 4, 4, 4, 4, 4)
)
expect_true("Bound" %in% colnames(observed))

# excluding "bound" in col_vars
observed <- summary(
x,
col_vars = c(
"z", "~hr at bound", "nominal p", "Alternate hypothesis", "Null hypothesis"
),
col_decimals = c(4, 4, 4, 4, 4)
)
expect_true("Bound" %in% colnames(observed))
})
Loading