diff --git a/R/global_vars.R b/R/global_vars.R deleted file mode 100644 index f31ec1439..000000000 --- a/R/global_vars.R +++ /dev/null @@ -1,17 +0,0 @@ -# defining global variables and functions to appease R CMD Check - -utils::globalVariables( - names = c( - ".", - "CI_high", - "CI_low", - "estimate", - "Estimate", - "grp", - "Parameter", - "predictor", - "ROPE_Equivalence", - "x_intercept", - "y_max" - ) -) diff --git a/R/plot.check_predictions.R b/R/plot.check_predictions.R index 4490e17b8..84bcba225 100644 --- a/R/plot.check_predictions.R +++ b/R/plot.check_predictions.R @@ -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 @@ -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")) { 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")) { @@ -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 @@ -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")) { @@ -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], @@ -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) } @@ -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( diff --git a/R/plot.equivalence_test.R b/R/plot.equivalence_test.R index fb3d23472..73eae78cc 100644 --- a/R/plot.equivalence_test.R +++ b/R/plot.equivalence_test.R @@ -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], @@ -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], @@ -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( diff --git a/R/plot.n_factors.R b/R/plot.n_factors.R index 0e88a255e..3e647918f 100644 --- a/R/plot.n_factors.R +++ b/R/plot.n_factors.R @@ -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)) + diff --git a/R/plot.performance_simres.R b/R/plot.performance_simres.R index 1dc95307e..eb0e3021e 100644 --- a/R/plot.performance_simres.R +++ b/R/plot.performance_simres.R @@ -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), diff --git a/R/plots.R b/R/plots.R index 996427084..f7fd14512 100644 --- a/R/plots.R +++ b/R/plots.R @@ -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) { @@ -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, @@ -92,8 +90,6 @@ plots <- function(..., caption = caption, theme = theme ) - - return(pw) } diff --git a/man/plot.see_performance_simres.Rd b/man/plot.see_performance_simres.Rd index b96e4e92e..e338c64ff 100644 --- a/man/plot.see_performance_simres.Rd +++ b/man/plot.see_performance_simres.Rd @@ -56,7 +56,7 @@ The \code{plot()} method for the \code{performance::check_residuals()} resp. \code{performance::simulate_residuals()} function. } \examples{ -\dontshow{if (insight::check_if_installed("performance", "0.10.9.7") && require("glmmTMB") && require("qqplotr") && require("DHARMa")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontshow{if (require("glmmTMB") && require("qqplotr") && require("DHARMa")) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} data(Salamanders, package = "glmmTMB") model <- glmmTMB::glmmTMB( count ~ mined + spp + (1 | site), diff --git a/man/print.see_performance_pp_check.Rd b/man/print.see_performance_pp_check.Rd index 0d6fc9096..5d5c41e4c 100644 --- a/man/print.see_performance_pp_check.Rd +++ b/man/print.see_performance_pp_check.Rd @@ -16,7 +16,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, ... ) @@ -32,7 +32,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, ... )