From d9c8f4187e934655613958562127a6d5df503f89 Mon Sep 17 00:00:00 2001 From: jgabry Date: Wed, 17 Jan 2024 12:58:44 -0700 Subject: [PATCH] fix R cmd check issues --- R/mcmc-diagnostics-nuts.R | 4 ++-- R/mcmc-diagnostics.R | 4 ++-- R/mcmc-distributions.R | 8 ++++---- R/mcmc-traces.R | 12 ++++++------ R/ppc-errors.R | 6 +++--- tests/testthat/test-ppc-distributions.R | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/R/mcmc-diagnostics-nuts.R b/R/mcmc-diagnostics-nuts.R index 30f565f2..00db3240 100644 --- a/R/mcmc-diagnostics-nuts.R +++ b/R/mcmc-diagnostics-nuts.R @@ -180,7 +180,7 @@ mcmc_nuts_acceptance <- } hists <- hists + dont_expand_y_axis(c(0.005, 0)) + - facet_wrap(vars(Parameter), scales = "free") + + facet_wrap(vars(.data$Parameter), scales = "free") + yaxis_text(FALSE) + yaxis_title(FALSE) + yaxis_ticks(FALSE) + @@ -476,7 +476,7 @@ mcmc_nuts_energy <- } graph + - facet_wrap(vars(Chain)) + + facet_wrap(vars(.data$Chain)) + force_axes_in_facets() } diff --git a/R/mcmc-diagnostics.R b/R/mcmc-diagnostics.R index 02ac547a..23960f15 100644 --- a/R/mcmc-diagnostics.R +++ b/R/mcmc-diagnostics.R @@ -519,8 +519,8 @@ drop_NAs_and_warn <- function(x) { plot_data <- acf_data(x = x, lags = lags) if (num_chains(x) > 1) { - facet_args$rows <- vars(Chain) - facet_args$cols <- vars(Parameter) + facet_args$rows <- vars(.data$Chain) + facet_args$cols <- vars(.data$Parameter) facet_fun <- "facet_grid" } else { # 1 chain facet_args$facets <- "Parameter" diff --git a/R/mcmc-distributions.R b/R/mcmc-distributions.R index 0576accb..07a1951a 100644 --- a/R/mcmc-distributions.R +++ b/R/mcmc-distributions.R @@ -405,13 +405,13 @@ mcmc_violin <- function( facet_args[["scales"]] <- facet_args[["scales"]] %||% "free" if (!by_chain) { if (n_param > 1) { - facet_args[["facets"]] <- vars(Parameter) + facet_args[["facets"]] <- vars(.data$Parameter) graph <- graph + do.call("facet_wrap", facet_args) } } else { - facet_args[["rows"]] <- vars(Chain) + facet_args[["rows"]] <- vars(.data$Chain) if (n_param > 1) { - facet_args[["cols"]] <- vars(Parameter) + facet_args[["cols"]] <- vars(.data$Parameter) } graph <- graph + do.call("facet_grid", facet_args) + @@ -526,7 +526,7 @@ mcmc_violin <- function( labs(x = if (violin) "Chain" else levels(data$Parameter), y = if (violin) levels(data$Parameter) else NULL) } else { - facet_args[["facets"]] <- vars(Parameter) + facet_args[["facets"]] <- vars(.data$Parameter) facet_args[["scales"]] <- facet_args[["scales"]] %||% "free" graph <- graph + do.call("facet_wrap", facet_args) } diff --git a/R/mcmc-traces.R b/R/mcmc-traces.R index e6a3e788..c5690b4b 100644 --- a/R/mcmc-traces.R +++ b/R/mcmc-traces.R @@ -335,7 +335,7 @@ mcmc_rank_overlay <- function(x, facet_call <- NULL if (n_param > 1) { - facet_args$facets <- vars(parameter) + facet_args$facets <- vars(.data$parameter) facet_args$scales <- facet_args$scales %||% "fixed" facet_call <- do.call("facet_wrap", facet_args) } @@ -387,16 +387,16 @@ mcmc_rank_hist <- function(x, right_edge <- max(data_boundaries$value_rank) facet_args[["scales"]] <- facet_args[["scales"]] %||% "fixed" - facet_args[["rows"]] <- facet_args[["rows"]] %||% vars(parameter) - facet_args[["cols"]] <- facet_args[["cols"]] %||% vars(chain) # If there is one parameter, put the chains in one row. # Otherwise, use a grid. if (n_param > 1) { facet_f <- facet_grid - names(facet_args)[names(facet_args) == "facets"] <- "rows" + facet_args[["rows"]] <- facet_args[["rows"]] %||% vars(.data$parameter) + facet_args[["cols"]] <- facet_args[["cols"]] %||% vars(.data$chain) } else { facet_f <- facet_wrap + facet_args[["facets"]] <- vars(.data$parameter, .data$chain) facet_args[["nrow"]] <- facet_args[["nrow"]] %||% 1 labeller <- function(x) label_value(x, multi_line = FALSE) facet_args[["labeller"]] <- facet_args[["labeller"]] %||% labeller @@ -528,7 +528,7 @@ mcmc_rank_ecdf <- if (n_param == 1) { facet_call <- ylab(levels(data$parameter)) } else { - facet_args$facets <- vars(parameter) + facet_args$facets <- vars(.data$parameter) facet_args$scales <- facet_args$scales %||% "free" facet_call <- do.call("facet_wrap", facet_args) } @@ -707,7 +707,7 @@ mcmc_trace_data <- function(x, if (n_param == 1) { facet_call <- ylab(levels(data$parameter)) } else { - facet_args$facets <- vars(parameter) + facet_args$facets <- vars(.data$parameter) facet_args$scales <- facet_args$scales %||% "free" facet_call <- do.call("facet_wrap", facet_args) } diff --git a/R/ppc-errors.R b/R/ppc-errors.R index 5902b441..00452121 100644 --- a/R/ppc-errors.R +++ b/R/ppc-errors.R @@ -398,11 +398,11 @@ error_hist_facets <- if (grouped) { facet_fun <- "facet_grid" - facet_args[["rows"]] <- vars(rep_id) - facet_args[["cols"]] <- vars(group) + facet_args[["rows"]] <- vars(.data$rep_id) + facet_args[["cols"]] <- vars(.data$group) } else { facet_fun <- "facet_wrap" - facet_args[["facets"]] <- vars(rep_id) + facet_args[["facets"]] <- vars(.data$rep_id) } facet_args[["scales"]] <- facet_args[["scales"]] %||% scales_default diff --git a/tests/testthat/test-ppc-distributions.R b/tests/testthat/test-ppc-distributions.R index c89eb28b..eb77240f 100644 --- a/tests/testthat/test-ppc-distributions.R +++ b/tests/testthat/test-ppc-distributions.R @@ -39,7 +39,7 @@ test_that("ppc_dens,pp_hist,ppc_freqpoly,ppc_boxplot return ggplot objects", { expect_gg(p <- ppc_hist(y, yrep[1:8, ], binwidth = 3)) if (utils::packageVersion("ggplot2") >= "3.0.0") { facet_var <- vars(rep_label) - expect_equal(as.character(p$facet$params$facets[1]), facet_var) + expect_equal(p$facet$params$facets[[1]], facet_var[[1]]) } # ppd versions