Skip to content

Commit 22e4406

Browse files
committed
allow bound functions and spending functions to take character values
1 parent 0ee27bc commit 22e4406

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

R/gs_design_ahr.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ gs_design_ahr <- function(
199199
info_frac <- 1
200200
}
201201
info_scale <- match.arg(info_scale)
202+
upper <- match.fun(upper)
203+
lower <- match.fun(lower)
202204

203205
# Check inputs ----
204206
check_analysis_time(analysis_time)
@@ -213,7 +215,7 @@ gs_design_ahr <- function(
213215
# Check if alpha is same as alpha spending ----
214216
if (identical(upper, gs_spending_bound)) {
215217
if (!is.null(upar$total_spend)) {
216-
if (methods::missingArg(alpha)) {
218+
if (missing(alpha)) {
217219
alpha <- upar$total_spend
218220
} else {
219221
if (alpha != upar$total_spend) {

R/gs_design_npe.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,8 @@ gs_design_npe <- function(
275275
check_theta(theta0, n_analysis)
276276
check_theta(theta1, n_analysis)
277277

278+
upper <- match.fun(upper)
279+
lower <- match.fun(lower)
278280
# check test_upper & test_lower
279281
if (length(test_upper) == 1 && n_analysis > 1) test_upper <- rep(test_upper, n_analysis)
280282
if (length(test_lower) == 1 && n_analysis > 1) test_lower <- rep(test_lower, n_analysis)

R/gs_power_npe.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ gs_power_npe <- function(theta = .1, theta0 = NULL, theta1 = NULL, # 3 theta
243243
} else if (length(theta1) == 1) {
244244
theta1 <- rep(theta1, n_analysis)
245245
}
246+
upper <- match.fun(upper)
247+
lower <- match.fun(lower)
246248
if (length(test_upper) == 1 && n_analysis > 1) test_upper <- rep(test_upper, n_analysis)
247249
if (length(test_lower) == 1 && n_analysis > 1) test_lower <- rep(test_lower, n_analysis)
248250

R/gs_spending_bound.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,13 @@ gs_spending_bound <- function(k = 1,
121121
}
122122

123123
# Compute cumulative spending at each analyses ----
124-
spend <- par$sf(alpha = par$total_spend, t = timing, param = par$param)$spend
124+
if (!is.function(sf <- par$sf)) sf <- tryCatch(match.fun(sf), error = function(e) {
125+
# in case gsDesign is not attached (i.e. library(gsDesign)) or the spending
126+
# function is not imported into gsDesign2 from gsDesign, we will get it from
127+
# gsDesign's namespace
128+
getExportedValue('gsDesign', sf)
129+
})
130+
spend <- sf(alpha = par$total_spend, t = timing, param = par$param)$spend
125131

126132
# Compute incremental spending at each analyses ----
127133
old_spend <- 0

0 commit comments

Comments
 (0)