Skip to content

Commit 84f1e70

Browse files
committed
Some minor clean-up
1 parent cb8ccb9 commit 84f1e70

9 files changed

+36
-56
lines changed

R/global_vars.R

-17
This file was deleted.

R/plot.check_distribution.R

+4-6
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,9 @@ plot.see_check_distribution <- function(x, size_point = 2, panel = TRUE, ...) {
108108
theme_lucid()
109109

110110
if (panel) {
111-
insight::check_if_installed("patchwork")
112-
return(p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2))
111+
p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2)
113112
} else {
114-
return(list(p1, p2, p3))
113+
list(p1, p2, p3)
115114
}
116115
}
117116

@@ -184,9 +183,8 @@ plot.see_check_distribution_numeric <- function(x,
184183
theme_lucid()
185184

186185
if (panel) {
187-
insight::check_if_installed("patchwork")
188-
return(p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2L))
186+
p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2L)
189187
} else {
190-
return(list(p1, p2, p3))
188+
list(p1, p2, p3)
191189
}
192190
}

R/plot.check_predictions.R

+17-14
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ print.see_performance_pp_check <- function(x,
9696
line_alpha = 0.15,
9797
style = theme_lucid,
9898
colors = unname(social_colors(c("green", "blue"))),
99-
type = c("density", "discrete_dots", "discrete_interval", "discrete_both"),
99+
type = "density",
100100
x_limits = NULL,
101101
...) {
102102
orig_x <- x
@@ -107,7 +107,10 @@ print.see_performance_pp_check <- function(x,
107107
if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) {
108108
type <- plot_type
109109
} else {
110-
type <- match.arg(type)
110+
type <- insight::validate_argument(
111+
type,
112+
c("density", "discrete_dots", "discrete_interval", "discrete_both")
113+
)
111114
}
112115

113116
if (!inherits(x, "data_plot")) {
@@ -153,7 +156,7 @@ plot.see_performance_pp_check <- function(x,
153156
line_alpha = 0.15,
154157
style = theme_lucid,
155158
colors = unname(social_colors(c("green", "blue"))),
156-
type = c("density", "discrete_dots", "discrete_interval", "discrete_both"),
159+
type = "density",
157160
x_limits = NULL,
158161
...) {
159162
orig_x <- x
@@ -164,7 +167,10 @@ plot.see_performance_pp_check <- function(x,
164167
if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) { # nolint
165168
type <- plot_type
166169
} else {
167-
type <- match.arg(type)
170+
type <- insight::validate_argument(
171+
type,
172+
c("density", "discrete_dots", "discrete_interval", "discrete_both")
173+
)
168174
}
169175

170176
if (!inherits(x, "data_plot")) {
@@ -451,7 +457,7 @@ plot.see_performance_pp_check <- function(x,
451457
subtitle <- "Model-predicted points should be close to observed data points"
452458
}
453459

454-
p <- p +
460+
p +
455461
ggplot2::scale_y_continuous() +
456462
ggplot2::scale_color_manual(values = c(
457463
"Observed data" = colors[1],
@@ -470,8 +476,6 @@ plot.see_performance_pp_check <- function(x,
470476
color = ggplot2::guide_legend(reverse = TRUE),
471477
size = ggplot2::guide_legend(reverse = TRUE)
472478
)
473-
474-
return(p)
475479
}
476480

477481

@@ -543,13 +547,12 @@ plot.see_performance_pp_check <- function(x,
543547
.plot_pp_check_range <- function(x,
544548
size_bar = 0.7,
545549
colors = unname(social_colors(c("green", "blue")))) {
546-
original <-
547-
data.frame(
548-
x = c(min(x$y), max(x$y)),
549-
group = factor(c("Minimum", "Maximum"), levels = c("Minimum", "Maximum")),
550-
color = "Observed data",
551-
stringsAsFactors = FALSE
552-
)
550+
original <- data.frame(
551+
x = c(min(x$y), max(x$y)),
552+
group = factor(c("Minimum", "Maximum"), levels = c("Minimum", "Maximum")),
553+
color = "Observed data",
554+
stringsAsFactors = FALSE
555+
)
553556

554557
replicated <- rbind(
555558
data.frame(

R/plot.equivalence_test.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,11 @@ plot.see_equivalence_test_lm <- function(x,
399399
p <- ggplot(
400400
x,
401401
aes(
402-
y = Parameter,
403-
x = Estimate,
404-
xmin = CI_low,
405-
xmax = CI_high,
406-
colour = ROPE_Equivalence
402+
y = .data$Parameter,
403+
x = .data$Estimate,
404+
xmin = .data$CI_low,
405+
xmax = .data$CI_high,
406+
colour = .data$ROPE_Equivalence
407407
)
408408
) +
409409
annotate(

R/plot.n_factors.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,19 @@ plot.see_n_factors <- function(x,
139139
segment_data <- data.frame(x_intercept = x$x[which.max(x$y)], y_max = max(x$y, na.rm = TRUE))
140140
p <- ggplot(x, aes(x = .data$x, y = .data$y)) +
141141
geom_area(fill = flat_colors("grey")) +
142-
geom_segment(
142+
geom_segment(
143143
data = segment_data,
144144
aes(
145-
x = x_intercept,
146-
xend = x_intercept,
145+
x = .data$x_intercept,
146+
xend = .data$x_intercept,
147147
y = 0,
148-
yend = y_max
148+
yend = .data$y_max
149149
),
150150
color = flat_colors("red")
151151
) +
152152
geom_point(
153153
data = segment_data,
154-
aes(x = x_intercept, y = y_max),
154+
aes(x = .data$x_intercept, y = .data$y_max),
155155
color = flat_colors("red")
156156
) +
157157
scale_x_continuous(breaks = 1:max(x$x, na.rm = TRUE)) +

R/plot.performance_simres.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#'
1515
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).
1616
#'
17-
#' @examplesIf insight::check_if_installed("performance", "0.10.9.7") && require("glmmTMB") && require("qqplotr") && require("DHARMa")
17+
#' @examplesIf require("glmmTMB") && require("qqplotr") && require("DHARMa")
1818
#' data(Salamanders, package = "glmmTMB")
1919
#' model <- glmmTMB::glmmTMB(
2020
#' count ~ mined + spp + (1 | site),

R/plots.R

+1-5
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ plots <- function(...,
6464
subtitle = NULL,
6565
caption = NULL,
6666
theme = NULL) {
67-
insight::check_if_installed("patchwork")
68-
6967
# Add tags
7068
if (!is.null(tags)) {
7169
if (length(tags) == 1L) {
@@ -81,7 +79,7 @@ plots <- function(...,
8179
}
8280
}
8381

84-
pw <- patchwork::wrap_plots(..., nrow = n_rows, ncol = n_columns, guides = guides) +
82+
patchwork::wrap_plots(..., nrow = n_rows, ncol = n_columns, guides = guides) +
8583
patchwork::plot_annotation(
8684
tag_levels = tags,
8785
tag_prefix = tag_prefix,
@@ -92,8 +90,6 @@ plots <- function(...,
9290
caption = caption,
9391
theme = theme
9492
)
95-
96-
return(pw)
9793
}
9894

9995

man/plot.see_performance_simres.Rd

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/print.see_performance_pp_check.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)