diff --git a/R/utils.R b/R/utils.R index 788b05868..87cbf49ac 100644 --- a/R/utils.R +++ b/R/utils.R @@ -38,7 +38,7 @@ .clean_parameter_names <- function(params, grid = FALSE) { params <- unique(params) - labels <- params + parameter_labels <- params # clean parameters names params <- gsub("(b_|bs_|bsp_|bcs_)(.*)", "\\2", params, perl = TRUE) @@ -90,7 +90,7 @@ params <- gsub("(Zero-Inflated) (Random)", "(Random, Zero-Inflated)", params, fixed = TRUE) } - stats::setNames(params, labels) + stats::setNames(params, parameter_labels) } @@ -139,8 +139,8 @@ .remove_intercept <- function(x, column = "Parameter", show_intercept = FALSE) { if (!show_intercept) { - remove <- which(.is_intercept(x[[column]])) - if (length(remove)) x <- x[-remove, ] + to_remove <- which(.is_intercept(x[[column]])) + if (length(to_remove)) x <- x[-to_remove, ] } x } diff --git a/R/utils_add_prior_layer.R b/R/utils_add_prior_layer.R index 8c2dbab76..90b0dbbac 100644 --- a/R/utils_add_prior_layer.R +++ b/R/utils_add_prior_layer.R @@ -17,8 +17,8 @@ # limit xrange, to avoid overly wide plots x_range <- stats::median(dens$x) + 7 * stats::mad(dens$x) * c(-1, 1) - remove <- which(dens$x <= x_range[1] | dens$x >= x_range[2]) - if (length(remove)) dens <- dens[-remove, ] + to_remove <- which(dens$x <= x_range[1] | dens$x >= x_range[2]) + if (length(to_remove)) dens <- dens[-to_remove, ] # remove intercept from output, if requested .remove_intercept(dens, column = "Parameter", show_intercept) @@ -60,35 +60,33 @@ na.rm = TRUE ) } + } else if (isTRUE(show_ridge_line)) { + ggridges::geom_ridgeline( + data = dat, + mapping = aes( + x = .data$x, + y = as.factor(.data$Parameter), + height = .data$y, + group = as.factor(.data$Parameter), + fill = "Priors" + ), + alpha = priors_alpha, + na.rm = TRUE + ) } else { - if (isTRUE(show_ridge_line)) { - ggridges::geom_ridgeline( - data = dat, - mapping = aes( - x = .data$x, - y = as.factor(.data$Parameter), - height = .data$y, - group = as.factor(.data$Parameter), - fill = "Priors" - ), - alpha = priors_alpha, - na.rm = TRUE - ) - } else { - ggridges::geom_ridgeline( - data = dat, - mapping = aes( - x = .data$x, - y = as.factor(.data$Parameter), - height = .data$y, - group = as.factor(.data$Parameter), - fill = "Priors" - ), - alpha = priors_alpha, - color = NA, - na.rm = TRUE - ) - } + ggridges::geom_ridgeline( + data = dat, + mapping = aes( + x = .data$x, + y = as.factor(.data$Parameter), + height = .data$y, + group = as.factor(.data$Parameter), + fill = "Priors" + ), + alpha = priors_alpha, + color = NA, + na.rm = TRUE + ) } } } @@ -115,8 +113,8 @@ # limit xrange, to avoid overly wide plots x_range <- stats::median(dens$x) + 7 * stats::mad(dens$x) * c(-1, 1) - remove <- which(dens$x <= x_range[1] | dens$x >= x_range[2]) - if (length(remove)) dens <- dens[-remove, ] + to_remove <- which(dens$x <= x_range[1] | dens$x >= x_range[2]) + if (length(to_remove)) dens <- dens[-to_remove, ] # remove intercept from output, if requested .remove_intercept(dens, column = "Parameter", show_intercept)