Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor clean-up #374

Merged
merged 8 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -67,7 +67,7 @@
#'
#' @return A ggplot2-object.
#'
#' @seealso See also the vignette about [`check_model()`](https://easystats.github.io/performance/articles/check_model.html).

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

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_predictions.R,line=70,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.

Check warning on line 70 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=70,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 125 characters.
#'
#' @examples
#' library(performance)
Expand Down Expand Up @@ -96,7 +96,7 @@
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 @@ -104,10 +104,13 @@
plot_type <- attributes(x)$type
is_stan <- attributes(x)$is_stan

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 @@
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 @@
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 @@ -204,7 +210,7 @@
base_size = 10,
size_axis_title = 10,
size_title = 12,
colors,

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

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/plot.check_predictions.R,line=213,col=28,[function_argument_linter] Arguments without defaults should come before arguments with defaults.

Check warning on line 213 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=213,col=28,[function_argument_linter] Arguments without defaults should come before arguments with defaults.
type = "density",
x_limits = NULL,
is_stan = NULL,
Expand Down Expand Up @@ -450,7 +456,7 @@
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 @@
color = ggplot2::guide_legend(reverse = TRUE),
size = ggplot2::guide_legend(reverse = TRUE)
)

return(p)
}


Expand Down Expand Up @@ -542,13 +546,12 @@
.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 @@ -12,9 +12,9 @@
#'
#' @return A ggplot2-object.
#'
#' @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.

Loading