Skip to content

Commit

Permalink
Fix conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
edelarua committed Nov 2, 2023
1 parent 7dcc773 commit 783e868
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R/analyze_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ a_summary <- function(x,
lbls <- get_labels_from_stats(.stats, .labels)
# Check for custom labels from control_analyze_vars
.labels <- if ("control" %in% names(list(...))) {
lbls %>% labels_use_control(control, .labels)
lbls %>% labels_use_control(list(...)[["control"]], .labels)
} else {
lbls
}
Expand Down
6 changes: 4 additions & 2 deletions R/utils_default_stats_formats_labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,15 @@ labels_use_control <- function(labels_default, control, labels_custom = NULL) {
}
)
}
if ("quantiles" %in% names(control) && !"quantiles" %in% names(labels_custom)) {
if ("quantiles" %in% names(control) && "quantiles" %in% names(labels_default) &&
!"quantiles" %in% names(labels_custom)) { # nolint
labels_default["quantiles"] <- gsub(
"[0-9]+% and [0-9]+", paste0(control[["quantiles"]][1] * 100, "% and ", control[["quantiles"]][2] * 100, ""),
labels_default["quantiles"]
)
}
if ("test_mean" %in% names(control) && !"mean_pval" %in% names(labels_custom)) {
if ("test_mean" %in% names(control) && "mean_pval" %in% names(labels_default) &&
!"mean_pval" %in% names(labels_custom)) { # nolint
labels_default["mean_pval"] <- gsub(
"p-value \\(H0: mean = [0-9\\.]+\\)", f_pval(control[["test_mean"]]), labels_default["mean_pval"]
)
Expand Down

0 comments on commit 783e868

Please sign in to comment.