Skip to content

Commit

Permalink
fix R cmd check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Jan 17, 2024
1 parent 3c2fa5f commit d9c8f41
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions R/mcmc-diagnostics-nuts.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -476,7 +476,7 @@ mcmc_nuts_energy <-
}

graph +
facet_wrap(vars(Chain)) +
facet_wrap(vars(.data$Chain)) +
force_axes_in_facets()
}

Expand Down
4 changes: 2 additions & 2 deletions R/mcmc-diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions R/mcmc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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) +
Expand Down Expand Up @@ -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)
}
Expand Down
12 changes: 6 additions & 6 deletions R/mcmc-traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions R/ppc-errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-ppc-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d9c8f41

Please sign in to comment.