Skip to content

Commit

Permalink
Some minor clean-up (#374)
Browse files Browse the repository at this point in the history
* Some minor clean-up

* fix

* revert change

* fix

* revert

* styler

---------

Co-authored-by: Indrajeet Patil <[email protected]>
  • Loading branch information
strengejacke and IndrajeetPatil authored Dec 5, 2024
1 parent 7eb57aa commit e8ecf7b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 51 deletions.
17 changes: 0 additions & 17 deletions R/global_vars.R

This file was deleted.

31 changes: 17 additions & 14 deletions R/plot.check_predictions.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ print.see_performance_pp_check <- function(x,
alpha_line = 0.15,
style = theme_lucid,
colors = unname(social_colors(c("green", "blue"))),
type = c("density", "discrete_dots", "discrete_interval", "discrete_both"),
type = "density",
x_limits = NULL,
...) {
orig_x <- x
Expand All @@ -107,7 +107,10 @@ print.see_performance_pp_check <- function(x,
if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) {

Check warning on line 107 in R/plot.check_predictions.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_predictions.R,line=107,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 131 characters.
type <- plot_type
} else {
type <- match.arg(type)
type <- insight::validate_argument(
type,
c("density", "discrete_dots", "discrete_interval", "discrete_both")
)
}

if (!inherits(x, "data_plot")) {
Expand Down Expand Up @@ -153,7 +156,7 @@ plot.see_performance_pp_check <- function(x,
alpha_line = 0.15,
style = theme_lucid,
colors = unname(social_colors(c("green", "blue"))),
type = c("density", "discrete_dots", "discrete_interval", "discrete_both"),
type = "density",
x_limits = NULL,
...) {
orig_x <- x
Expand All @@ -164,7 +167,10 @@ plot.see_performance_pp_check <- function(x,
if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) { # nolint
type <- plot_type
} else {
type <- match.arg(type)
type <- insight::validate_argument(
type,
c("density", "discrete_dots", "discrete_interval", "discrete_both")
)
}

if (!inherits(x, "data_plot")) {
Expand Down Expand Up @@ -450,7 +456,7 @@ plot.see_performance_pp_check <- function(x,
subtitle <- "Model-predicted points should be close to observed data points"
}

p <- p +
p +
ggplot2::scale_y_continuous() +
ggplot2::scale_color_manual(values = c(
"Observed data" = colors[1],
Expand All @@ -469,8 +475,6 @@ plot.see_performance_pp_check <- function(x,
color = ggplot2::guide_legend(reverse = TRUE),
size = ggplot2::guide_legend(reverse = TRUE)
)

return(p)
}


Expand Down Expand Up @@ -542,13 +546,12 @@ plot.see_performance_pp_check <- function(x,
.plot_pp_check_range <- function(x,
size_bar = 0.7,
colors = unname(social_colors(c("green", "blue")))) {
original <-
data.frame(
x = c(min(x$y), max(x$y)),
group = factor(c("Minimum", "Maximum"), levels = c("Minimum", "Maximum")),
color = "Observed data",
stringsAsFactors = FALSE
)
original <- data.frame(
x = c(min(x$y), max(x$y)),
group = factor(c("Minimum", "Maximum"), levels = c("Minimum", "Maximum")),
color = "Observed data",
stringsAsFactors = FALSE
)

replicated <- rbind(
data.frame(
Expand Down
14 changes: 7 additions & 7 deletions R/plot.equivalence_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ plot.see_equivalence_test <- function(x,

insight::check_if_installed("ggridges")

p <- ggplot(tmp, aes(x = estimate, y = predictor, fill = grp)) +
p <- ggplot(tmp, aes(x = .data$estimate, y = .data$predictor, fill = .data$grp)) +
annotate(
"rect",
xmin = .rope[1],
Expand Down Expand Up @@ -281,7 +281,7 @@ plot.see_equivalence_test_df <- function(x,

insight::check_if_installed("ggridges")

p <- ggplot(tmp, aes(x = estimate, y = predictor, fill = grp)) +
p <- ggplot(tmp, aes(x = .data$estimate, y = .data$predictor, fill = .data$grp)) +
annotate(
"rect",
xmin = .rope[1],
Expand Down Expand Up @@ -396,11 +396,11 @@ plot.see_equivalence_test_lm <- function(x,
p <- ggplot(
x,
aes(
y = Parameter,
x = Estimate,
xmin = CI_low,
xmax = CI_high,
colour = ROPE_Equivalence
y = .data$Parameter,
x = .data$Estimate,
xmin = .data$CI_low,
xmax = .data$CI_high,
colour = .data$ROPE_Equivalence
)
) +
annotate(
Expand Down
8 changes: 4 additions & 4 deletions R/plot.n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ plot.see_n_factors <- function(x,
geom_segment(
data = segment_data,
aes(
x = x_intercept,
xend = x_intercept,
x = .data$x_intercept,
xend = .data$x_intercept,
y = 0,
yend = y_max
yend = .data$y_max
),
color = flat_colors("red")
) +
geom_point(
data = segment_data,
aes(x = x_intercept, y = y_max),
aes(x = .data$x_intercept, y = .data$y_max),
color = flat_colors("red")
) +
scale_x_continuous(breaks = 1:max(x$x, na.rm = TRUE)) +
Expand Down
2 changes: 1 addition & 1 deletion R/plot.performance_simres.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#'
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).
#'
#' @examplesIf insight::check_if_installed("performance", "0.10.9.7") && require("glmmTMB") && require("qqplotr") && require("DHARMa")
#' @examplesIf require("glmmTMB") && require("qqplotr") && require("DHARMa")
#' data(Salamanders, package = "glmmTMB")
#' model <- glmmTMB::glmmTMB(
#' count ~ mined + spp + (1 | site),
Expand Down
6 changes: 1 addition & 5 deletions R/plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ plots <- function(...,
subtitle = NULL,
caption = NULL,
theme = NULL) {
insight::check_if_installed("patchwork")

# Add tags
if (!is.null(tags)) {
if (length(tags) == 1L) {
Expand All @@ -81,7 +79,7 @@ plots <- function(...,
}
}

pw <- patchwork::wrap_plots(..., nrow = n_rows, ncol = n_columns, guides = guides) +
patchwork::wrap_plots(..., nrow = n_rows, ncol = n_columns, guides = guides) +
patchwork::plot_annotation(
tag_levels = tags,
tag_prefix = tag_prefix,
Expand All @@ -92,8 +90,6 @@ plots <- function(...,
caption = caption,
theme = theme
)

return(pw)
}


Expand Down
2 changes: 1 addition & 1 deletion man/plot.see_performance_simres.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/print.see_performance_pp_check.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e8ecf7b

Please sign in to comment.