Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
7edda8c
new unified get_ref_info
munoztd0 Jul 17, 2026
a4a59f3
new unified get_ref_info()
munoztd0 Jul 17, 2026
bba7576
fix: examples and redocument
munoztd0 Jul 17, 2026
2ed9cd8
fix: merge issues
munoztd0 Jul 17, 2026
9f32e7c
get_ref_info() update - refectored body proposal.
wwojciech Jul 17, 2026
35098b8
lintr update for cur_col_split_path_utils.
wwojciech Jul 17, 2026
25d0501
refactor: trt_var / ctrl_grp -> split_var / ref_level
munoztd0 Aug 14, 2026
aef5bc2
test: make get_ref_info tests more specific to the exact length
munoztd0 Aug 14, 2026
9b74cd1
Merge remote-tracking branch 'origin/dev' into new_unified_get_ref_info
munoztd0 Aug 14, 2026
13e6de1
Merge branch 'new_unified_get_ref_info' of https://github.com/johnson…
munoztd0 Aug 14, 2026
8693deb
refactor: rename test
munoztd0 Aug 14, 2026
19515d3
rename split_var split_name instead to reflect the changes
munoztd0 Aug 14, 2026
ed49a65
lintr
munoztd0 Aug 14, 2026
2f39367
f**** lint
munoztd0 Aug 14, 2026
7c726d7
lean get_ref_info
munoztd0 Aug 18, 2026
f4706f6
refactor `h_get_trtvar_refpath()` and `a_summarize_aval_chg_diff_j()`
munoztd0 Aug 18, 2026
41e519e
lint + document
munoztd0 Aug 18, 2026
942062f
get_ref_info(): man update.
wwojciech Aug 18, 2026
baaa112
h_get_trtvar_refpath(): cosmetic code update.
wwojciech Aug 18, 2026
08a9830
refactor
munoztd0 Aug 19, 2026
aef4f7f
refactor
munoztd0 Aug 19, 2026
3e10ceb
updated h_get_trtvar_refpath() - PLEASE UPDATE UPSTREAM CODE RESPECTI…
wwojciech Aug 20, 2026
27840b8
update h_get_trtvar_refpath() and its upstream dependencies. What is …
wwojciech Aug 20, 2026
cb143e0
styler only.
wwojciech Aug 20, 2026
41d6366
fix(h_get_trtvar_refpath): match trt var by name not position..
munoztd0 Aug 20, 2026
afb42b3
vingette for get_ref_info
munoztd0 Aug 20, 2026
5429a35
Merge branch 'dev' into new_unified_get_ref_info
munoztd0 Aug 20, 2026
89e2e58
added match + is.na defensice checks
munoztd0 Aug 20, 2026
e0c3811
use pharmaverseadamjnj instead for examples
munoztd0 Aug 20, 2026
830ba97
Added regression test
munoztd0 Aug 21, 2026
df9bb77
Implemented the positional trt_var suggestion
munoztd0 Aug 21, 2026
83396fb
replace h_get_trtvar_refpath() with h_get_cur_trt_grp(). The UPSTREAM…
wwojciech Aug 22, 2026
2218cf3
cosmetic a_freq_j() update.
wwojciech Aug 22, 2026
df4a1c9
Added strict_match().
wwojciech Aug 24, 2026
3984069
unexport
munoztd0 Aug 24, 2026
1669baf
test: add unit test for strict_match
munoztd0 Aug 24, 2026
1acd4a0
fix #446 . Update all the code (afuns) that uses the old h_get_trtvar…
munoztd0 Aug 24, 2026
8acd022
adde assertions 6. ) assertions should be added to all other functio…
munoztd0 Aug 24, 2026
2b8ab97
add dont run
munoztd0 Aug 24, 2026
3ba2bb7
lintr
munoztd0 Aug 24, 2026
8a1cc0f
Merge branch 'dev' into new_unified_get_ref_info
munoztd0 Aug 24, 2026
1bba4f1
fthis
munoztd0 Aug 25, 2026
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: junco
Title: Create Common Tables and Listings Used in Clinical Trials
Version: 0.1.6.9000
Version: 0.1.6.9001
Date: 2026-05-22
Authors@R: c(
person("Gabriel", "Becker", , "gabembecker@gmail.com", role = c("cre", "aut"),
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ export(get_visit_levels)
export(grouped_cols_w_diffs)
export(h_extract_coxreg_multivar)
export(h_get_design_mat)
export(h_get_trtvar_refpath)
export(h_tidy_pool)
export(in_column)
export(inches_to_spaces)
Expand Down
8 changes: 6 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# junco 0.1.6.9000
# junco 0.1.6.9001

### Fixed
- Fixed `get_ref_info()` to accept ref_path = NULL (#359).
Expand All @@ -9,11 +9,14 @@

### Changed

- Updated several analysis functions to use `h_get_cur_trt_grp()` (#295).
- Replaced `h_get_trtvar_refpath()` with `h_get_cur_trt_grp()` (#295).
- Updated `get_ref_info()` for matching column split paths (#295).
- Added the new helper function `factor_by_order()` (#425).
- Renamed `in_ref_col()` to `in_column()` and renamed its `ref_path` argument
to `col_path`.
- Updated `in_ref_col()` to accept `ref_path = NULL` (#404).
- Added the new helper functions `cur_col_split_path()` and `in_ref_col()` to
- Added the new helper functions `cur_col_split_path()` and `in_column()` to
support custom analysis functions that depend on the current column split
context (#404).
- Added a default value for the `label` argument in `c_summary_subset_label()`.
Expand Down Expand Up @@ -42,6 +45,7 @@
- Add extra statistics to `a_eair100_j` and introduce scaling factor `num_p_year` (default = 100) (#361)

### Added
- Added `strict_match()` for uniquely matching a value in the odd or even positions of a character vector.
- Added `categorize_pval()` for assigning p-values to validated, user-defined categories.
- Added `pool_rubin_scalar()` and `pool_z_stat()` for pooling scalar estimates and z statistics across imputations.
- Added `resp_multiple_imputation()` to impute missing binary responses across scenarios and pool CMH risk-difference and p-value results.
Expand Down
38 changes: 15 additions & 23 deletions R/a_freq_j.R
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,9 @@ a_freq_j <- function(
colgroup = NULL,
countsource = c("df", "altdf", "altdf_subset")
) {
checkmate::check_character(ref_path, min.len = 2L)
checkmate::assert_true(length(ref_path) %% 2L == 0L)

denom <- match.arg(denom)
method <- match.arg(method)

Expand Down Expand Up @@ -913,7 +916,6 @@ a_freq_j <- function(
if (riskdiff && is.null(ref_path)) {
stop("argument ref_path cannot be NULL.")
}
### denom N_colgroup should not be used in layout with risk diff columns
if (denom == "N_colgroup") {
stop(
"denom N_colgroup cannot be used in a layout with risk diff columns."
Expand All @@ -923,28 +925,11 @@ a_freq_j <- function(
trt_var <- NULL
ctrl_grp <- NULL
cur_trt_grp <- NULL
}

if (riskdiff) {
trt_var_refpath <- h_get_trtvar_refpath(
ref_path,
.spl_context,
df
)
# trt_var_refpath is list with elements
# trt_var trt_var_refspec cur_trt_grp ctrl_grp
# make these elements available in current environment
trt_var <- trt_var_refpath$trt_var
trt_var_refspec <- trt_var_refpath$trt_var_refspec
cur_trt_grp <- trt_var_refpath$cur_trt_grp
ctrl_grp <- trt_var_refpath$ctrl_grp
# for combined facet, denom_df value for the treatment group needs update
new_denomdf <- upd_denom_df_combo(
new_denomdf,
trt_var,
cur_trt_grp,
.spl_context
)
} else {
trt_var <- ref_path[length(ref_path) - 1L]
ctrl_grp <- ref_path[length(ref_path)]
stopifnot(ctrl_grp %in% levels(df[[trt_var]]))
cur_trt_grp <- h_get_cur_trt_grp(trt_var, .spl_context)

if (!is.null(colgroup) && trt_var == colgroup) {
stop(
Expand All @@ -953,6 +938,13 @@ a_freq_j <- function(
Either remove risk difference columns from layout, set riskdiff = FALSE, or update colgroup."
)
}

new_denomdf <- upd_denom_df_combo(
new_denomdf,
trt_var,
cur_trt_grp,
.spl_context
)
}

x_stats <- s_rel_risk_val_j(
Expand Down
75 changes: 35 additions & 40 deletions R/a_freq_resp_var_j.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,38 @@
#'
#' result
a_freq_resp_var_j <- function(
df,
.var,
.df_row,
.N_col,
.spl_context,
resp_var = NULL,
id = "USUBJID",
drop_levels = FALSE,
riskdiff = TRUE,
ref_path = NULL,
variables = formals(s_proportion_diff)$variables,
conf_level = formals(s_proportion_diff)$conf_level,
method = c(
"wald",
"waldcc",
"cmh",
"ha",
"newcombe",
"newcombecc",
"strat_newcombe",
"strat_newcombecc",
"cmh_sato",
"cmh_mn",
"uncond_exact_diff"
),
weights_method = formals(s_proportion_diff)$weights_method,
.formats = NULL,
na_str = rep("NA", 3)) {
df,
.var,
.df_row,
.N_col,
.spl_context,
resp_var = NULL,
id = "USUBJID",
drop_levels = FALSE,
riskdiff = TRUE,
ref_path = NULL,
variables = formals(s_proportion_diff)$variables,
conf_level = formals(s_proportion_diff)$conf_level,
method = c(
"wald",
"waldcc",
"cmh",
"ha",
"newcombe",
"newcombecc",
"strat_newcombe",
"strat_newcombecc",
"cmh_sato",
"cmh_mn",
"uncond_exact_diff"
),
weights_method = formals(s_proportion_diff)$weights_method,
.formats = NULL,
na_str = rep("NA", 3)
) {
checkmate::check_character(ref_path, min.len = 2L)
checkmate::assert_true(length(ref_path) %% 2L == 0L)

# ---- Derive statistics: xx / xx (xx.x%)

if (is.null(resp_var)) {
Expand Down Expand Up @@ -137,18 +141,9 @@ a_freq_resp_var_j <- function(
inriskdiffcol <- grepl("difference", tolower(colid), fixed = TRUE)

if (riskdiff) {
trt_var_refpath <- h_get_trtvar_refpath(
ref_path,
.spl_context,
df
)
# trt_var_refpath is list with elements
# trt_var trt_var_refspec cur_trt_grp ctrl_grp
# make these elements available in current environment
trt_var <- trt_var_refpath$trt_var
trt_var_refspec <- trt_var_refpath$trt_var_refspec
cur_trt_grp <- trt_var_refpath$cur_trt_grp
ctrl_grp <- trt_var_refpath$ctrl_grp
trt_var <- ref_path[length(ref_path) - 1L]
ctrl_grp <- ref_path[length(ref_path)]
cur_trt_grp <- h_get_cur_trt_grp(trt_var, .spl_context)
}

fn <- function(levii) {
Expand Down
104 changes: 49 additions & 55 deletions R/a_summarize_aval_chg_diff.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,24 @@ s_aval_chg_col1 <- function(df, .var, denom, .N_col, id, indatavar) {
}

s_aval_chg_col23_diff <- function(
df,
.var,
.df_row,
.ref_group,
.in_ref_col,
ancova,
interaction_y,
interaction_item,
conf_level,
variables,
trt_var,
ctrl_grp,
cur_param,
cur_lvl,
weights_emmeans,
method_combo,
weights_combo) {
df,
.var,
.df_row,
.ref_group,
.in_ref_col,
ancova,
interaction_y,
interaction_item,
conf_level,
variables,
trt_var,
ctrl_grp,
cur_param,
cur_lvl,
weights_emmeans,
method_combo,
weights_combo
) {
.df_row <- subset(.df_row, !is.na(.df_row[[.var]]))
df <- subset(df, !is.na(df[[.var]]))
.ref_group <- subset(.ref_group, !is.na(.ref_group[[.var]]))
Expand Down Expand Up @@ -374,29 +375,33 @@ format_xxd <- function(str, d = 0, .df_row, formatting_fun = NULL) {
#' result
#' @family Inclusion of ANCOVA Functions
a_summarize_aval_chg_diff_j <- function(
df,
.df_row,
.spl_context,
ancova = FALSE,
comp_btw_group = TRUE,
ref_path = NULL,
.N_col,
denom = c("N", ".N_col"),
indatavar = NULL,
d = 0,
id = "USUBJID",
interaction_y = FALSE,
interaction_item = NULL,
conf_level = 0.95,
variables = list(arm = "TRT01A", covariates = NULL),
format_na_str = "",
.stats = list(col1 = "count_denom_frac", col23 = "mean_ci_3d", coldiff = "meandiff_ci_3d"),
.formats = list(col1 = NULL, col23 = "xx.dx (xx.dx, xx.dx)", coldiff = "xx.dx (xx.dx, xx.dx)"),
.formats_fun = list(col1 = jjcsformat_count_denom_fraction, col23 = jjcsformat_xx, coldiff = jjcsformat_xx),
multivars = c("AVAL", "AVAL", "CHG"),
weights_emmeans = NULL,
method_combo = c("contrasts", "collapse"),
weights_combo = NULL) {
df,
.df_row,
.spl_context,
ancova = FALSE,
comp_btw_group = TRUE,
ref_path = NULL,
.N_col,
denom = c("N", ".N_col"),
indatavar = NULL,
d = 0,
id = "USUBJID",
interaction_y = FALSE,
interaction_item = NULL,
conf_level = 0.95,
variables = list(arm = "TRT01A", covariates = NULL),
format_na_str = "",
.stats = list(col1 = "count_denom_frac", col23 = "mean_ci_3d", coldiff = "meandiff_ci_3d"),
.formats = list(col1 = NULL, col23 = "xx.dx (xx.dx, xx.dx)", coldiff = "xx.dx (xx.dx, xx.dx)"),
.formats_fun = list(col1 = jjcsformat_count_denom_fraction, col23 = jjcsformat_xx, coldiff = jjcsformat_xx),
multivars = c("AVAL", "AVAL", "CHG"),
weights_emmeans = NULL,
method_combo = c("contrasts", "collapse"),
weights_combo = NULL
) {
checkmate::check_character(ref_path, min.len = 2L)
checkmate::assert_true(length(ref_path) %% 2L == 0L)

denom <- match.arg(denom)
method_combo <- match.arg(method_combo)

Expand Down Expand Up @@ -474,22 +479,11 @@ a_summarize_aval_chg_diff_j <- function(

.in_ref_col <- FALSE
.ref_group <- NULL
ctrl_grp <- NULL
if (comp_btw_group) {
trt_var_refspec <- utils::tail(ref_path, n = 2)[1]
checkmate::assert_true(identical(trt_var, trt_var_refspec))
# ctrl_grp
ctrl_grp <- utils::tail(ref_path, n = 1)

### check that ctrl_grp is a level of the treatment variable, in case riskdiff is requested
if (!ctrl_grp %in% levels(df[[trt_var]])) {
stop(paste0(
"control group specification in ref_path argument (",
ctrl_grp,
") is not a level of your treatment group variable (",
trt_var,
")."
))
}
checkmate::assert_true(identical(trt_var, ref_path[length(ref_path) - 1L]))
ctrl_grp <- ref_path[length(ref_path)]
stopifnot(ctrl_grp %in% levels(df[[trt_var]]))

if (trt_val == ctrl_grp) .in_ref_col <- TRUE

Expand Down
Loading
Loading