Skip to content

Commit

Permalink
styler, lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Sep 5, 2024
1 parent c542ba2 commit 101cf0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion R/plot.check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ plot.see_performance_pp_check <- function(x,
size = ggplot2::guide_legend(reverse = TRUE)
)

return(p)
p
}


Expand Down
25 changes: 11 additions & 14 deletions R/plot.equivalence_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ plot.see_equivalence_test <- function(x,
}

# get labels
labels <- .clean_parameter_names(tmp$predictor, grid = !is.null(n_columns))
axis_labels <- .clean_parameter_names(tmp$predictor, grid = !is.null(n_columns))

tmp <- .fix_facet_names(tmp)

Expand All @@ -126,11 +126,11 @@ plot.see_equivalence_test <- function(x,

fill.color <- fill.color[sort(unique(match(x$ROPE_Equivalence, c("Accepted", "Rejected", "Undecided"))))]

add.args <- lapply(match.call(expand.dots = FALSE)$`...`, function(x) x)
add.args <- lapply(match.call(expand.dots = FALSE)[["..."]], function(x) x)
if ("colors" %in% names(add.args)) fill.color <- eval(add.args[["colors"]])
if ("x.title" %in% names(add.args)) x.title <- eval(add.args[["x.title"]])
if ("legend.title" %in% names(add.args)) legend.title <- eval(add.args[["legend.title"]])
if ("labels" %in% names(add.args)) labels <- eval(add.args[["labels"]])
if ("labels" %in% names(add.args)) axis_labels <- eval(add.args[["labels"]])

rope.line.alpha <- 1.25 * rope_alpha
if (rope.line.alpha > 1) rope.line.alpha <- 1
Expand Down Expand Up @@ -170,7 +170,7 @@ plot.see_equivalence_test <- function(x,
) +
scale_fill_manual(values = fill.color) +
labs(x = x.title, y = NULL, fill = legend.title) +
scale_y_discrete(labels = labels) +
scale_y_discrete(labels = axis_labels) +
theme(legend.position = "bottom")

if (!is.null(n_columns)) {
Expand All @@ -193,10 +193,8 @@ plot.see_equivalence_test <- function(x,
p <- p + facet_wrap(~Component, scales = "free", ncol = n_columns)
}
}
} else {
if (length(unique(tmp$HDI)) > 1L) {
p <- p + facet_wrap(~HDI, scales = "free", ncol = n_columns)
}
} else if (length(unique(tmp$HDI)) > 1L) {
p <- p + facet_wrap(~HDI, scales = "free", ncol = n_columns)
}

p
Expand Down Expand Up @@ -259,7 +257,7 @@ plot.see_equivalence_test_df <- function(x,
tmp$predictor <- factor(tmp$predictor, levels = rev(unique(tmp$predictor)))

# get labels
labels <- .clean_parameter_names(tmp$predictor, grid = !is.null(n_columns))
axis_labels <- .clean_parameter_names(tmp$predictor, grid = !is.null(n_columns))

# check for user defined arguments

Expand All @@ -273,11 +271,11 @@ plot.see_equivalence_test_df <- function(x,

fill.color <- fill.color[sort(unique(match(x$ROPE_Equivalence, c("Accepted", "Rejected", "Undecided"))))]

add.args <- lapply(match.call(expand.dots = FALSE)$`...`, function(x) x)
add.args <- lapply(match.call(expand.dots = FALSE)[["..."]], function(x) x)
if ("colors" %in% names(add.args)) fill.color <- eval(add.args[["colors"]])
if ("x.title" %in% names(add.args)) x.title <- eval(add.args[["x.title"]])
if ("legend.title" %in% names(add.args)) legend.title <- eval(add.args[["legend.title"]])
if ("labels" %in% names(add.args)) labels <- eval(add.args[["labels"]])
if ("labels" %in% names(add.args)) axis_labels <- eval(add.args[["labels"]])

rope.line.alpha <- 1.25 * rope_alpha

Expand Down Expand Up @@ -317,7 +315,7 @@ plot.see_equivalence_test_df <- function(x,
) +
scale_fill_manual(values = fill.color) +
labs(x = x.title, y = NULL, fill = legend.title) +
scale_y_discrete(labels = labels) +
scale_y_discrete(labels = axis_labels) +
theme(legend.position = "bottom")

if (length(unique(tmp$HDI)) > 1L) {
Expand Down Expand Up @@ -390,11 +388,10 @@ plot.see_equivalence_test_lm <- function(x,

fill.color <- fill.color[sort(unique(match(x$ROPE_Equivalence, c("Accepted", "Rejected", "Undecided"))))]

add.args <- lapply(match.call(expand.dots = FALSE)$`...`, function(x) x)
add.args <- lapply(match.call(expand.dots = FALSE)[["..."]], function(x) x)
if ("colors" %in% names(add.args)) fill.color <- eval(add.args[["colors"]])
if ("x.title" %in% names(add.args)) x.title <- eval(add.args[["x.title"]])
if ("legend.title" %in% names(add.args)) legend.title <- eval(add.args[["legend.title"]])
if ("labels" %in% names(add.args)) labels <- eval(add.args[["labels"]])

rope.line.alpha <- 1.25 * rope_alpha
if (rope.line.alpha > 1) rope.line.alpha <- 1
Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
params <- gsub("(b_|bs_|bsp_|bcs_)(.*)", "\\2", params, perl = TRUE)
params <- gsub("^cond_(.*)", "\\1 (Conditional)", params, perl = TRUE)
params <- gsub("(.*)_cond$", "\\1 (Conditional)", params, perl = TRUE)
params <- gsub("^zi_(.*)", "\\1 (Zero-Inflated)", params, perl = TRUE)
params <- gsub("^zi_(.*)", "\\1 (Zero-Inflated)", params, perl = TRUE)
params <- gsub("(.*)_zi$", "\\1 (Zero-Inflated)", params, perl = TRUE)
params <- gsub("(.*)_disp$", "\\1 (Dispersion)", params, perl = TRUE)
# clean random effect parameters names
Expand Down

0 comments on commit 101cf0d

Please sign in to comment.