diff --git a/DESCRIPTION b/DESCRIPTION index 594e8405e..09b9d9978 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -117,4 +117,4 @@ Config/Needs/website: rstudio/bslib, r-lib/pkgdown, easystats/easystatstemplate -Remotes: easystats/insight, easystats/bayestestR +Remotes: easystats/bayestestR diff --git a/R/plot.hdi.R b/R/plot.hdi.R index 03b33e79c..fd8d08e8e 100644 --- a/R/plot.hdi.R +++ b/R/plot.hdi.R @@ -199,7 +199,7 @@ data_plot.bayestestR_eti <- data_plot.hdi #' library(bayestestR) #' set.seed(123) #' m <- suppressWarnings(stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)) -#' result <- hdi(m) +#' result <- bayestestR::hdi(m) #' result #' plot(result) #' diff --git a/R/plot.parameters_brms_meta.R b/R/plot.parameters_brms_meta.R index b1cacb760..7558d83ad 100644 --- a/R/plot.parameters_brms_meta.R +++ b/R/plot.parameters_brms_meta.R @@ -129,7 +129,9 @@ data_plot.parameters_brms_meta <- function(x, data = NULL, normalize_height = TR #' prior(normal(0, 1), class = Intercept), #' prior(cauchy(0, 0.5), class = sd) #' ) -#' model <- brm(yi | se(vi) ~ 1 + (1 | author), data = dat) +#' model <- suppressWarnings( +#' brm(yi | se(vi) ~ 1 + (1 | author), data = dat) +#' ) #' #' # result #' mp <- model_parameters(model) diff --git a/R/plot.parameters_model.R b/R/plot.parameters_model.R index 0b4ec0fe1..7cbba6ecb 100644 --- a/R/plot.parameters_model.R +++ b/R/plot.parameters_model.R @@ -513,7 +513,9 @@ plot.see_parameters_model <- function(x, } else if (has_response) { p <- p + facet_wrap(~Response, ncol = n_columns, scales = facet_scales) } else if (has_subgroups) { - suppressWarnings(p <- p + facet_grid(Subgroup ~ ., scales = "free", space = "free")) # nolint + suppressWarnings({ + p <- p + facet_grid(Subgroup ~ ., scales = "free", space = "free") + }) } if (length(model_attributes$parameter_names) > 1L) { diff --git a/R/plot.parameters_pca.R b/R/plot.parameters_pca.R index 0b10ae0fe..8d754ca67 100644 --- a/R/plot.parameters_pca.R +++ b/R/plot.parameters_pca.R @@ -33,6 +33,8 @@ data_plot.parameters_pca <- function(x, data = NULL, ...) { title <- paste0("Rotated loadings from ", title, " (", rotation_name, ")") } + # remove missing values in y, to avoid warning + dataplot <- dataplot[!is.na(dataplot$y), ] attr(dataplot, "info") <- list( "xlab" = "", diff --git a/R/plot.si.R b/R/plot.si.R index 479d7b023..3e7edfa06 100644 --- a/R/plot.si.R +++ b/R/plot.si.R @@ -17,7 +17,7 @@ #' library(bayestestR) #' set.seed(123) #' m <<- suppressWarnings(stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)) -#' result <- si(m) +#' result <- si(m, verbose = FALSE) #' result #' plot(result) #' diff --git a/R/plot.visualisation_recipe.R b/R/plot.visualisation_recipe.R index 6bb5d7077..dd8e81ea6 100644 --- a/R/plot.visualisation_recipe.R +++ b/R/plot.visualisation_recipe.R @@ -5,11 +5,10 @@ plot.see_visualisation_recipe <- function(x, ...) { if (!"ggraph" %in% .packages()) { attachNamespace("ggraph") # Needs to be attached } - ggraph::ggraph(attributes(x)$data, layout = attributes(x)$layout) + - geoms_from_list(x) + suppressWarnings(ggraph::ggraph(attributes(x)$data, layout = attributes(x)$layout) + geoms_from_list(x)) } else { - ggplot2::ggplot(data = attributes(x)$data) + - geoms_from_list(x, ...) + suppressWarnings(ggplot2::ggplot(data = attributes(x)$data) + + geoms_from_list(x, ...)) } } @@ -23,7 +22,7 @@ plot.see_visualisation_recipe <- function(x, ...) { plot.see_visualisation_recipes <- function(x, ...) { the_plots <- list() for (i in names(x)) { - the_plots[[i]] <- graphics::plot(x[[i]]) + the_plots[[i]] <- suppressWarnings(graphics::plot(x[[i]])) } pw <- plots(the_plots, ...) .safe_print_plots(pw) diff --git a/R/print.check_model.R b/R/print.check_model.R index 96902c44e..8f684d49f 100644 --- a/R/print.check_model.R +++ b/R/print.check_model.R @@ -9,13 +9,13 @@ print.see_check_model <- function(x, # to plot(), "type" is no longer recognized as "missing()" plot_type <- attr(x, "type") - if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) { + 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, choices = c("density", "discrete_dots", "discrete_interval", "discrete_both")) } - suppressWarnings(suppressMessages(plot( + suppressWarnings(suppressMessages(graphics::plot( x, style = style, colors = colors, diff --git a/R/utils.R b/R/utils.R index 383a15b34..788b05868 100644 --- a/R/utils.R +++ b/R/utils.R @@ -7,10 +7,12 @@ return(x) } + .as.data.frame_density <- function(x, ...) { data.frame(x = x$x, y = x$y) } + # safe conversion from factor to numeric .factor_to_numeric <- function(x) { if (is.numeric(x)) { @@ -27,11 +29,13 @@ as.numeric(as.character(x)) } + .has_multiple_panels <- function(x) { (!"Effects" %in% names(x) || insight::n_unique(x$Effects) <= 1L) && (!"Component" %in% names(x) || insight::n_unique(x$Component) <= 1L) } + .clean_parameter_names <- function(params, grid = FALSE) { params <- unique(params) labels <- params @@ -90,7 +94,6 @@ } - .fix_facet_names <- function(x) { if ("Component" %in% names(x)) { x$Component <- as.character(x$Component) @@ -117,7 +120,6 @@ } - .intercept_names <- c( "(intercept)_zi", diff --git a/man/plot.see_hdi.Rd b/man/plot.see_hdi.Rd index 9b6f89430..ef2fc4f93 100644 --- a/man/plot.see_hdi.Rd +++ b/man/plot.see_hdi.Rd @@ -50,7 +50,7 @@ library(rstanarm) library(bayestestR) set.seed(123) m <- suppressWarnings(stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)) -result <- hdi(m) +result <- bayestestR::hdi(m) result plot(result) \dontshow{\}) # examplesIf} diff --git a/man/plot.see_parameters_brms_meta.Rd b/man/plot.see_parameters_brms_meta.Rd index 626f6140e..502f8c255 100644 --- a/man/plot.see_parameters_brms_meta.Rd +++ b/man/plot.see_parameters_brms_meta.Rd @@ -84,7 +84,9 @@ priors <- c( prior(normal(0, 1), class = Intercept), prior(cauchy(0, 0.5), class = sd) ) -model <- brm(yi | se(vi) ~ 1 + (1 | author), data = dat) +model <- suppressWarnings( + brm(yi | se(vi) ~ 1 + (1 | author), data = dat) +) # result mp <- model_parameters(model) diff --git a/man/plot.see_si.Rd b/man/plot.see_si.Rd index 8b8dea8a9..7ea480514 100644 --- a/man/plot.see_si.Rd +++ b/man/plot.see_si.Rd @@ -44,7 +44,7 @@ library(rstanarm) library(bayestestR) set.seed(123) m <<- suppressWarnings(stan_glm(Sepal.Length ~ Petal.Width * Species, data = iris, refresh = 0)) -result <- si(m) +result <- si(m, verbose = FALSE) result plot(result) \dontshow{\}) # examplesIf} diff --git a/vignettes/bayestestR.Rmd b/vignettes/bayestestR.Rmd index 57cf7b851..dec57202f 100644 --- a/vignettes/bayestestR.Rmd +++ b/vignettes/bayestestR.Rmd @@ -361,7 +361,7 @@ represent the density of the null at the value - the ratio of their heights is the value of the Savage-Dickey Bayes factor: ```{r} -result <- bayesfactor_parameters(model) +result <- bayesfactor_parameters(model, verbose = FALSE) result diff --git a/vignettes/modelbased.Rmd b/vignettes/modelbased.Rmd index be62a7e2d..064407e30 100644 --- a/vignettes/modelbased.Rmd +++ b/vignettes/modelbased.Rmd @@ -122,12 +122,18 @@ plot(result) ``` -```{r slopes-poly} +```{r slopes-poly, echo=TRUE, eval=FALSE} model <- lm(Petal.Length ~ Species * poly(Sepal.Width, 3), data = iris) result <- estimate_slopes(model, at = c("Sepal.Width", "Species")) plot(result) ``` +```{r slopes-poly2, eval=can_evaluate, echo=FALSE} +model <- lm(Petal.Length ~ Species * poly(Sepal.Width, 3), data = iris) + +result <- estimate_slopes(model, at = c("Sepal.Width", "Species")) +suppressWarnings(print(plot(result))) +``` # Estimate derivatives diff --git a/vignettes/parameters.Rmd b/vignettes/parameters.Rmd index de801f42a..92b3836c4 100644 --- a/vignettes/parameters.Rmd +++ b/vignettes/parameters.Rmd @@ -190,7 +190,7 @@ density estimation plots [from Bayesian models](https://easystats.github.io/see/articles/bayestestR.html). ```{r} -result <- simulate_parameters(model1) +result <<- simulate_parameters(model1) plot(result) ``` @@ -245,7 +245,12 @@ estimations](https://easystats.github.io/see/articles/bayestestR.html)). # family = zero_inflated_poisson() # ) brms_model <- insight::download_model("brms_zi_2") -result <- model_parameters(brms_model, effects = "all", component = "all") +result <- model_parameters( + brms_model, + effects = "all", + component = "all", + verbose = FALSE +) plot(result) ``` @@ -255,7 +260,9 @@ plot(result) ```{r} result <- model_parameters(brms_model, effects = "all", - component = "all", group_level = TRUE + component = "all", + group_level = TRUE, + verbose = FALSE ) plot(result) ```