Skip to content

Commit e05af13

Browse files
authored
Adding test to check if plot-methods broke (#390)
* Adding test to check if plot-methods broke Fixes #364 * add test * lintr * update * update * resolve TODO * revert change * styler * update test * update snap
1 parent 9a361bd commit e05af13

12 files changed

+126
-33
lines changed

DESCRIPTION

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: see
33
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
4-
Version: 0.10.0.9
4+
Version: 0.10.0.10
55
Authors@R:
66
c(person(given = "Daniel",
77
family = "Lüdecke",
@@ -88,7 +88,6 @@ Suggests:
8888
ggside,
8989
glmmTMB,
9090
grid,
91-
httr,
9291
httr2,
9392
lavaan,
9493
lme4,

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
appropriate palette (usually, `"contrast"` or `"gradient"`) depending on
2323
whether discrete or continuous color scales are requested.
2424

25+
## Bug fixes
26+
27+
* Fixed issue with adding prior layers to plots from `estimate_density()`.
28+
2529
# see 0.10.0
2630

2731
## Changes

R/geom_binomdensity.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ geom_binomdensity <- function(data,
5353
# Find y-axis levels
5454
y_levels <- levels(as.factor(data[[y]]))
5555
if (length(y_levels) != 2L) {
56-
stop("The y-variable should have exactly two levels.", call. = FALSE)
56+
insight::format_error("The y-variable should have exactly two levels.")
5757
}
5858

5959
# Aesthetics
@@ -110,7 +110,7 @@ geom_binomdensity <- function(data,
110110
}
111111
out <- as.vector(prop[as.character(data[[y]])] * 0.9)
112112
} else {
113-
stop("Oops, 'scale' argument wrongly specified.", call. = FALSE)
113+
insight::format_error("Oops, 'scale' argument wrongly specified.")
114114
}
115115

116116
out

R/plot.check_dag.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ plot.see_check_dag <- function(x,
6262
...) {
6363
.data <- NULL
6464
insight::check_if_installed(c("ggdag", "ggplot2"))
65-
which <- match.arg(which, choices = c("all", "current", "required"))
66-
effect <- match.arg(effect, choices = c("total", "direct"))
65+
which <- insight::validate_argument(which, c("all", "current", "required"))
66+
effect <- insight::validate_argument(effect, c("total", "direct"))
6767

6868
# get plot data
6969
p1 <- p2 <- suppressWarnings(ggdag::dag_adjustment_sets(x, effect = effect))

R/plot.dw_data_tabulate.R

+11-11
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
#' @param x Object created by `datawizard::data_tabulate()`.
44
#' @param label_values Logical. Should values and percentages be displayed at the
55
#' top of each bar.
6-
#' @param show_na Should missing values be dropped? Can be `"if_any"` (default) to show
7-
#' the missing category only if any missing values are present, `"always"` to
8-
#' always show the missing category, or `"never"` to never show the missing
9-
#' category.
6+
#' @param show_na Should missing values be dropped? Can be `"if_any"` (default)
7+
#' to show the missing category only if any missing values are present,
8+
#' `"always"` to always show the missing category, or `"never"` to never show
9+
#' the missing category.
1010
#' @param na_label The label given to missing values when they are shown.
11-
#' @param error_bar Logical. Should error bars be displayed?
12-
#' If `TRUE`, confidence intervals computed using the Wilson method are shown.
13-
#' See Brown et al. (2001) for details.
11+
#' @param error_bar Logical. Should error bars be displayed? If `TRUE`,
12+
#' confidence intervals computed using the Wilson method are shown. See Brown
13+
#' et al. (2001) for details.
1414
#' @param ci Confidence Interval (CI) level. Defaults to `0.95` (`95%`).
1515
#' @param color_fill Color to use for category columns (default: `"#87CEFA"`).
1616
#' @param color_error_bar Color to use for error bars (default: `"#607B8B"`).
@@ -25,14 +25,14 @@
2525
#' @export
2626

2727
plot.datawizard_tables <- function(x, label_values = TRUE,
28-
show_na = c("if_any", "always", "never"),
28+
show_na = "if_any",
2929
na_label = "(Missing)",
3030
error_bar = TRUE,
3131
ci = 0.95,
3232
color_fill = "#87CEFA",
3333
color_error_bar = "#607B8B",
3434
...) {
35-
show_na <- match.arg(show_na, choices = c("if_any", "always", "never"))
35+
show_na <- insight::validate_argument(show_na, c("if_any", "always", "never"))
3636
if (length(x) == 1L) {
3737
plot.datawizard_table(
3838
x[[1]],
@@ -64,14 +64,14 @@ plot.datawizard_tables <- function(x, label_values = TRUE,
6464
#' @export
6565

6666
plot.datawizard_table <- function(x, label_values = TRUE,
67-
show_na = c("if_any", "always", "never"),
67+
show_na = "if_any",
6868
na_label = "(Missing)",
6969
error_bar = TRUE,
7070
ci = 0.95,
7171
color_fill = "#87CEFA",
7272
color_error_bar = "#607B8B",
7373
...) {
74-
show_na <- match.arg(show_na, choices = c("if_any", "always", "never"))
74+
show_na <- insight::validate_argument(show_na, c("if_any", "always", "never"))
7575
dat <- as.data.frame(x)
7676

7777
if (show_na == "if_any") {

R/plot.estimate_density.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ plot.see_estimate_density <- function(x,
134134
}
135135

136136
# get parameter names for filtering
137-
params <- unique(x$y)
137+
params <- unique(x$Parameter)
138138

139139
# get labels
140140
parameter_labels <- .clean_parameter_names(x$Parameter, grid = !is.null(n_columns))

R/print.check_model.R

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ print.see_check_model <- function(x,
1212
if (missing(type) && !is.null(plot_type) && plot_type %in% c("density", "discrete_dots", "discrete_interval", "discrete_both")) { # nolint
1313
type <- plot_type
1414
} else {
15-
type <- match.arg(type, choices = c("density", "discrete_dots", "discrete_interval", "discrete_both"))
15+
type <- insight::validate_argument(
16+
type,
17+
c("density", "discrete_dots", "discrete_interval", "discrete_both")
18+
)
1619
}
1720

1821
suppressWarnings(suppressMessages(graphics::plot(

man/plot.datawizard_table.Rd

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)