Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jan 31, 2024
1 parent 07c2a33 commit 6bd6d81
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
8 changes: 4 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -90,7 +90,7 @@
params <- gsub("(Zero-Inflated) (Random)", "(Random, Zero-Inflated)", params, fixed = TRUE)
}

stats::setNames(params, labels)
stats::setNames(params, parameter_labels)
}


Expand Down Expand Up @@ -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
}
Expand Down
62 changes: 30 additions & 32 deletions R/utils_add_prior_layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
)
}
}
}
Expand All @@ -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)
Expand Down

0 comments on commit 6bd6d81

Please sign in to comment.