Skip to content

Add in missing analysis function option for custom statistics #1400

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

Merged
merged 4 commits into from
Feb 26, 2025
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
9 changes: 7 additions & 2 deletions R/abnormal.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ a_count_abnormal <- function(df,
extra_afun_params <- retrieve_extra_afun_params(names(dots_extra_args$.additional_fun_parameters))
dots_extra_args$.additional_fun_parameters <- NULL

# Check for user-defined functions
default_and_custom_stats_list <- .split_std_from_custom_stats(.stats)
.stats <- default_and_custom_stats_list$all_stats
custom_stat_functions <- default_and_custom_stats_list$custom_stats

# Apply statistics function
x_stats <- .apply_stat_functions(
default_stat_fnc = s_count_abnormal,
custom_stat_fnc_list = NULL,
custom_stat_fnc_list = custom_stat_functions,
args_list = c(
df = list(df),
extra_afun_params,
Expand All @@ -121,7 +126,7 @@ a_count_abnormal <- function(df,
)

# Fill in formatting defaults
.stats <- get_stats("abnormal", stats_in = .stats)
.stats <- get_stats("abnormal", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
levels_per_stats <- lapply(x_stats, names)
.formats <- get_formats_from_stats(.stats, .formats, levels_per_stats)
.labels <- get_labels_from_stats(.stats, .labels, levels_per_stats)
Expand Down
9 changes: 7 additions & 2 deletions R/abnormal_by_baseline.R
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,15 @@ a_count_abnormal_by_baseline <- function(df,
extra_afun_params <- retrieve_extra_afun_params(names(dots_extra_args$.additional_fun_parameters))
dots_extra_args$.additional_fun_parameters <- NULL

# Check for user-defined functions
default_and_custom_stats_list <- .split_std_from_custom_stats(.stats)
.stats <- default_and_custom_stats_list$all_stats
custom_stat_functions <- default_and_custom_stats_list$custom_stats

# Apply statistics function
x_stats <- .apply_stat_functions(
default_stat_fnc = s_count_abnormal_by_baseline,
custom_stat_fnc_list = NULL,
custom_stat_fnc_list = custom_stat_functions,
args_list = c(
df = list(df),
extra_afun_params,
Expand All @@ -148,7 +153,7 @@ a_count_abnormal_by_baseline <- function(df,
)

# Fill in formatting defaults
.stats <- get_stats("abnormal_by_baseline", stats_in = .stats)
.stats <- get_stats("abnormal_by_baseline", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
levels_per_stats <- lapply(x_stats, names)
.formats <- get_formats_from_stats(.stats, .formats, levels_per_stats)
.labels <- get_labels_from_stats(
Expand Down
9 changes: 7 additions & 2 deletions R/abnormal_by_marked.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,15 @@ a_count_abnormal_by_marked <- function(df,
extra_afun_params <- retrieve_extra_afun_params(names(dots_extra_args$.additional_fun_parameters))
dots_extra_args$.additional_fun_parameters <- NULL

# Check for user-defined functions
default_and_custom_stats_list <- .split_std_from_custom_stats(.stats)
.stats <- default_and_custom_stats_list$all_stats
custom_stat_functions <- default_and_custom_stats_list$custom_stats

# Apply statistics function
x_stats <- .apply_stat_functions(
default_stat_fnc = s_count_abnormal_by_marked,
custom_stat_fnc_list = NULL,
custom_stat_fnc_list = custom_stat_functions,
args_list = c(
df = list(df),
extra_afun_params,
Expand All @@ -132,7 +137,7 @@ a_count_abnormal_by_marked <- function(df,
)

# Fill in formatting defaults
.stats <- get_stats("abnormal_by_marked", stats_in = .stats)
.stats <- get_stats("abnormal_by_marked", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
levels_per_stats <- lapply(x_stats, names)
.formats <- get_formats_from_stats(.stats, .formats, levels_per_stats)
.labels <- get_labels_from_stats(.stats, .labels, levels_per_stats)
Expand Down
9 changes: 7 additions & 2 deletions R/abnormal_by_worst_grade.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,15 @@ a_count_abnormal_by_worst_grade <- function(df,
extra_afun_params <- retrieve_extra_afun_params(names(dots_extra_args$.additional_fun_parameters))
dots_extra_args$.additional_fun_parameters <- NULL

# Check for user-defined functions
default_and_custom_stats_list <- .split_std_from_custom_stats(.stats)
.stats <- default_and_custom_stats_list$all_stats
custom_stat_functions <- default_and_custom_stats_list$custom_stats

# Apply statistics function
x_stats <- .apply_stat_functions(
default_stat_fnc = s_count_abnormal_by_worst_grade,
custom_stat_fnc_list = NULL,
custom_stat_fnc_list = custom_stat_functions,
args_list = c(
df = list(df),
extra_afun_params,
Expand All @@ -119,7 +124,7 @@ a_count_abnormal_by_worst_grade <- function(df,
)

# Fill in formatting defaults
.stats <- get_stats("abnormal_by_worst_grade", stats_in = .stats)
.stats <- get_stats("abnormal_by_worst_grade", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
levels_per_stats <- lapply(x_stats, names)
.formats <- get_formats_from_stats(.stats, .formats, levels_per_stats)
.labels <- get_labels_from_stats(.stats, .labels, levels_per_stats)
Expand Down
13 changes: 11 additions & 2 deletions R/abnormal_lab_worsen_by_baseline.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ a_count_abnormal_lab_worsen_by_baseline <- function(df,
extra_afun_params <- retrieve_extra_afun_params(names(dots_extra_args$.additional_fun_parameters))
dots_extra_args$.additional_fun_parameters <- NULL

# Check for user-defined functions
default_and_custom_stats_list <- .split_std_from_custom_stats(.stats)
.stats <- default_and_custom_stats_list$all_stats
custom_stat_functions <- default_and_custom_stats_list$custom_stats

# Apply statistics function
x_stats <- .apply_stat_functions(
default_stat_fnc = s_count_abnormal_lab_worsen_by_baseline,
custom_stat_fnc_list = NULL,
custom_stat_fnc_list = custom_stat_functions,
args_list = c(
df = list(df),
extra_afun_params,
Expand All @@ -100,7 +105,11 @@ a_count_abnormal_lab_worsen_by_baseline <- function(df,
)

# Fill in formatting defaults
.stats <- get_stats("abnormal_lab_worsen_by_baseline", stats_in = .stats)
.stats <- get_stats(
"abnormal_lab_worsen_by_baseline",
stats_in = .stats,
custom_stats_in = names(custom_stat_functions)
)
levels_per_stats <- lapply(x_stats, names)
.formats <- get_formats_from_stats(.stats, .formats, levels_per_stats)
.labels <- get_labels_from_stats(.stats, .labels, levels_per_stats)
Expand Down
2 changes: 1 addition & 1 deletion R/summarize_ancova.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ a_ancova <- function(df,
)

# Fill in formatting defaults
.stats <- c(get_stats("summarize_ancova", stats_in = .stats), names(custom_stat_functions))
.stats <- get_stats("summarize_ancova", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
x_stats <- x_stats[.stats]
.formats <- get_formats_from_stats(.stats, .formats)
.labels <- get_labels_from_stats(
Expand Down
6 changes: 1 addition & 5 deletions R/summarize_change.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ a_change_from_baseline <- function(df,
)

# Fill in with formatting defaults if needed
.stats <- get_stats(
"analyze_vars_numeric",
stats_in = .stats,
custom_stats_in = names(custom_stat_functions),
)
.stats <- get_stats("analyze_vars_numeric", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
.formats <- get_formats_from_stats(.stats, .formats)
.labels <- get_labels_from_stats(.stats, .labels)
.indent_mods <- get_indents_from_stats(.stats, .indent_mods)
Expand Down
2 changes: 1 addition & 1 deletion R/summarize_glm_count.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ a_glm_count <- function(df,
)

# Fill in formatting defaults
.stats <- c(get_stats("summarize_glm_count", stats_in = .stats), names(custom_stat_functions))
.stats <- get_stats("summarize_glm_count", stats_in = .stats, custom_stats_in = names(custom_stat_functions))
.formats <- get_formats_from_stats(.stats, .formats)
.labels <- get_labels_from_stats(.stats, .labels)
.indent_mods <- get_indents_from_stats(.stats, .indent_mods)
Expand Down