Skip to content

Commit

Permalink
1st draft
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleBeannie committed Mar 18, 2024
1 parent d898847 commit 3d8fdee
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

S3method(as_gt,fixed_design)
S3method(as_gt,gs_design)
S3method(as_gt,gs_power_npe)
S3method(as_rtf,fixed_design)
S3method(as_rtf,gs_design)
S3method(summary,fixed_design)
Expand Down
50 changes: 50 additions & 0 deletions R/as_gt.R
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,53 @@ as_gt.gs_design <- function(

return(x)
}

#' @rdname as_gt
#' @export
#'
#' @examplesIf interactive() && !identical(Sys.getenv("IN_PKGDOWN"), "true")
#' x <- gs_power_npe(
#' theta = c(.1, .2, .3),
#' info = (1:3) * 40,
#' upper = gs_spending_bound,
#' upar = list(sf = gsDesign::sfLDOF, total_spend = 0.025, param = NULL, timing = NULL),
#' lower = gs_spending_bound,
#' lpar = list(sf = gsDesign::sfHSD, total_spend = 0.1, param = -1, timing = NULL))
#'
#' x |> as_gt()
as_gt.gs_power_npe <- function(
x,
title = "Bound summary",
subtitle = NULL,
display_bound = c("Efficacy", "Futility"),
display_inf_bound = TRUE,
...) {

# Filter out inf bound ----
if(!display_inf_bound) {

Check warning on line 581 in R/as_gt.R

View workflow job for this annotation

GitHub Actions / lint

file=R/as_gt.R,line=581,col=5,[spaces_left_parentheses_linter] Place a space before left parenthesis, except in a function call.
x <- x %>%filter(!is.infinite(z))

Check warning on line 582 in R/as_gt.R

View workflow job for this annotation

GitHub Actions / lint

file=R/as_gt.R,line=582,col=12,[infix_spaces_linter] Put spaces around all infix operators.
}

x <- x %>%
dplyr::select(analysis, bound, z, probability, theta, theta1, info, info0, info1, info_frac) %>%
dplyr::rename(Z = z,
Bound = bound,
`Cumulative boundary crossing probability` = probability,
`Information fraction` = info_frac) %>%
dplyr::arrange(analysis) %>%
dplyr::group_by(analysis) %>%
gt::gt() %>%
gt::fmt_number(columns = c(Z, `Cumulative boundary crossing probability`, `Information fraction`),
decimals = 4) %>%
gt::tab_spanner(
columns = c(theta, theta1),
label = c("Treatment effect (-log(AHR))")
) %>%
gt::tab_spanner(
columns = c(info, info0, info1),
label = c("Statistical information")
) %>%
gt::tab_header(title = title, subtitle = subtitle)

return(x)
}
1 change: 1 addition & 0 deletions R/gs_power_npe.R
Original file line number Diff line number Diff line change
Expand Up @@ -376,5 +376,6 @@ gs_power_npe <- function(theta = .1, theta0 = NULL, theta1 = NULL, # 3 theta
# filter(abs(Z) < Inf) %>%
arrange(desc(bound), analysis)

class(ans) <- c("gs_power_npe", class(ans))
return(ans)
}
21 changes: 21 additions & 0 deletions man/as_gt.Rd

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

0 comments on commit 3d8fdee

Please sign in to comment.