Skip to content

Commit

Permalink
Some minor clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 19, 2024
1 parent cb8ccb9 commit 84f1e70
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 56 deletions.
17 changes: 0 additions & 17 deletions R/global_vars.R

This file was deleted.

10 changes: 4 additions & 6 deletions R/plot.check_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,9 @@ plot.see_check_distribution <- function(x, size_point = 2, panel = TRUE, ...) {
theme_lucid()

if (panel) {
insight::check_if_installed("patchwork")
return(p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2))
p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2)
} else {
return(list(p1, p2, p3))
list(p1, p2, p3)
}
}

Expand Down Expand Up @@ -184,9 +183,8 @@ plot.see_check_distribution_numeric <- function(x,
theme_lucid()

if (panel) {
insight::check_if_installed("patchwork")
return(p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2L))
p1 / (p2 | p3) + patchwork::plot_layout(nrow = 2L)
} else {
return(list(p1, p2, p3))
list(p1, p2, p3)
}
}
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,
line_alpha = 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.

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

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

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,
line_alpha = 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 @@ -451,7 +457,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 @@ -470,8 +476,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 @@ -543,13 +547,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
10 changes: 5 additions & 5 deletions R/plot.equivalence_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,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
10 changes: 5 additions & 5 deletions R/plot.n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ plot.see_n_factors <- function(x,
segment_data <- data.frame(x_intercept = x$x[which.max(x$y)], y_max = max(x$y, na.rm = TRUE))
p <- ggplot(x, aes(x = .data$x, y = .data$y)) +
geom_area(fill = flat_colors("grey")) +
geom_segment(
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).

Check warning on line 15 in R/plot.performance_simres.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/plot.performance_simres.R,line=15,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @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 84f1e70

Please sign in to comment.