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

Clean up summary functions #461

Merged
merged 43 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
943121d
purely cosmetic changes
yihui Aug 30, 2024
6de4e78
use a single paste0()
yihui Aug 30, 2024
b26ed32
no need ot do.call(rbind, ...) or apply(..., paste): just paste the f…
yihui Aug 30, 2024
59047f3
use a regular expression \\U to capitalize the first letter
yihui Aug 30, 2024
f163e05
extra ,
yihui Aug 30, 2024
45f7a59
factor out `class(x) <- c(..., class(x))` to add_class()
yihui Aug 30, 2024
a0830bd
always add newline to files
yihui Aug 30, 2024
23f4207
factor out get_method()
yihui Aug 30, 2024
ea50328
merge all these `if` statements
yihui Aug 30, 2024
0c3190e
`ans` should inherit classes from `x` instead of `ans`
yihui Aug 30, 2024
cefeb5f
no need to create the object `x_design`; just assign to `ans$design`
yihui Aug 30, 2024
e3eaa16
untangle this complicated if-else hairball
yihui Aug 30, 2024
a405832
factor out replace_values()
yihui Aug 30, 2024
fdf14ae
batch capitalize variable names
yihui Aug 30, 2024
df565fd
the `mutate_at()` can be a simple `<-` assignment to column, and the …
yihui Aug 30, 2024
84a2754
use add_class()
yihui Aug 30, 2024
920b18c
use %||%
yihui Aug 30, 2024
b263d07
store col_vars in the names of col_decimals, and use names when we ne…
yihui Aug 30, 2024
84c46db
factor out get_decimals()
yihui Aug 30, 2024
08674f9
also apply get_decimals() to analysis variables and decimals, and ren…
yihui Aug 31, 2024
7401dbe
an alternative way to replace values in a vector
yihui Sep 3, 2024
59c939c
a simple helper function rename_to() to rename objects
yihui Sep 3, 2024
2b3de00
the columns have already been renamed before, and bound names have al…
yihui Sep 3, 2024
c18b536
don't round() if digits is not provided
yihui Sep 4, 2024
a54fcf2
simplify table_ab()
yihui Sep 4, 2024
d223dc0
rewrite round_df()
yihui Sep 4, 2024
004af38
factor out huge amount of code for renaming, and I'm too tired to exp…
yihui Sep 4, 2024
2c70436
factor out x$design_par
yihui Sep 5, 2024
0a69d8b
use the rename function
yihui Sep 5, 2024
b7c5c87
rename_to -> replace_names
yihui Sep 5, 2024
d00be63
get rid of the `dplyr::` qualifiers
yihui Sep 5, 2024
3c505d9
cosmetic
yihui Sep 5, 2024
c7ab5be
I think group_by() has sorted the data implicitly, so no need to arra…
yihui Sep 5, 2024
9cde29a
one assignment
yihui Sep 5, 2024
494e354
rename analysis header and bound details with the same function `cap_…
yihui Sep 5, 2024
df032cc
also use cap_names() for fixed design
yihui Sep 5, 2024
f724c3b
unnecessary to create the two objects `analysis_header` and `bound_de…
yihui Sep 5, 2024
774e3e4
remove unused argument of replace_values()
yihui Sep 5, 2024
9d66828
apply cap_names() on col_decimals
yihui Sep 5, 2024
92d2bfe
`<-` [ci skip]
yihui Sep 5, 2024
4f1de2a
import stats for setNames()
yihui Sep 5, 2024
b1a18fb
explain the substitute() trick
yihui Sep 5, 2024
9ba6c87
only import stats::setNames() since stats has filter(), which conflic…
yihui Sep 5, 2024
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: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ importFrom(dplyr,left_join)
importFrom(dplyr,mutate)
importFrom(dplyr,one_of)
importFrom(dplyr,rename)
importFrom(dplyr,row_number)
importFrom(dplyr,select)
importFrom(dplyr,summarize)
importFrom(dplyr,ungroup)
Expand All @@ -83,6 +84,7 @@ importFrom(gsDesign,sfLDOF)
importFrom(mvtnorm,GenzBretz)
importFrom(stats,pnorm)
importFrom(stats,qnorm)
importFrom(stats,setNames)
importFrom(stats,stepfun)
importFrom(stats,uniroot)
importFrom(survival,Surv)
Expand Down
5 changes: 3 additions & 2 deletions R/as_gt.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ as_gt.fixed_design <- function(x, title = NULL, footnote = NULL, ...) {
return(ans)
}

get_method <- function(x, methods) intersect(methods, class(x))[1]

# get the fixed design method
fd_method <- function(x) {
methods <- c("ahr", "fh", "mb", "lf", "rd", "maxcombo", "milestone", "rmst")
intersect(methods, class(x))[1]
get_method(x, c("ahr", "fh", "mb", "lf", "rd", "maxcombo", "milestone", "rmst"))
}

# get the default title
Expand Down
7 changes: 2 additions & 5 deletions R/gsDesign2-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#' @keywords internal
"_PACKAGE"

#' @useDynLib gsDesign2, .registration = TRUE
NULL

#' @importFrom stats setNames
#' @importFrom Rcpp sourceCpp
NULL
"_PACKAGE"
6 changes: 1 addition & 5 deletions R/gs_design_ahr.R
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,6 @@ gs_design_ahr <- function(
analysis = analysis
)

class(ans) <- c("ahr", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "ahr", "gs_design")
return(ans)
}
6 changes: 1 addition & 5 deletions R/gs_design_rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,6 @@ gs_design_rd <- function(p_c = tibble::tibble(stratum = "All", rate = .2),
analysis = analysis
)

class(ans) <- c("rd", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "rd", "gs_design")
return(ans)
}
6 changes: 1 addition & 5 deletions R/gs_design_wlr.R
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,6 @@ gs_design_wlr <- function(
analysis = analysis
)

class(ans) <- c("wlr", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "wlr", "gs_design")
return(ans)
}
6 changes: 1 addition & 5 deletions R/gs_power_ahr.R
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,6 @@ gs_power_ahr <- function(
analysis = analysis
)

class(ans) <- c("ahr", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "ahr", "gs_design")
return(ans)
}
6 changes: 1 addition & 5 deletions R/gs_power_rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,6 @@ gs_power_rd <- function(
analysis = analysis
)

class(ans) <- c("rd", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "rd", "gs_design")
return(ans)
}
6 changes: 1 addition & 5 deletions R/gs_power_wlr.R
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,7 @@ gs_power_wlr <- function(enroll_rate = define_enroll_rate(duration = c(2, 2, 10)
analysis = analysis
)

class(ans) <- c("wlr", "gs_design", class(ans))
if (!binding) {
class(ans) <- c("non_binding", class(ans))
}

ans <- add_class(ans, if (!binding) "non_binding", "wlr", "gs_design")
return(ans)
}

Expand Down
Loading