Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error with describe_distribution() with select #288

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.7.5.5
Version: 0.7.5.6
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

* Fixes issue in `plot.binned_residuals()` for models whose residuals were
completely inside error bounds.

* `plot()` now works when using it on the output of `describe_distribution()` with
a `select` argument of length 1.

# see 0.7.5

Expand Down
4 changes: 2 additions & 2 deletions R/plot.describe_distribution.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' @export
data_plot.parameters_distribution <- function(x, data = NULL, ...) {
if (nrow(x) == 1) {
if (nrow(x) == 1 && is.null(x$Variable)) {
dataplot <- data.frame(
x = data,
stringsAsFactors = FALSE
Expand Down Expand Up @@ -71,7 +71,7 @@ plot.see_parameters_distribution <- function(x,

# only keep variables used in "describe_distribution()"
if (!is.null(x$Variable)) {
data <- data[x$Variable]
data <- data[, x$Variable, drop = FALSE]
}

if (!inherits(x, "data_plot")) {
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-plot.describe_distribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,10 @@ test_that("`plot.see_parameters_distribution()` works", {
x <- sample(1:100, 1000, replace = TRUE)
result <- datawizard::describe_distribution(x)
expect_s3_class(plot(result), "gg")

result <- datawizard::describe_distribution(iris)
expect_true(all(vapply(plot(result), inherits, "gg", FUN.VALUE = logical(1L))))

result <- datawizard::describe_distribution(iris, select = "Sepal.Length")
expect_true(all(vapply(plot(result), inherits, "gg", FUN.VALUE = logical(1L))))
})