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: ggparcoord anyClass ordering with missing values in data #500

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
@@ -1,5 +1,7 @@
# GGally (development version)

* Fix anyClass ordering in ggparcoord when data has missing values (#500)

# GGally 2.2.1

* Fix compatibility with ggplot2 3.5.0 (@teunbrand, #481)
Expand Down
1 change: 1 addition & 0 deletions R/ggparcoord.R
Expand Up @@ -396,6 +396,7 @@ ggparcoord <- function(
}

data <- data[dataCompleteCases, ]
saveData2 <- saveData2[dataCompleteCases, ]
} else if (tolower(missing) %in% c("mean", "median", "min10", "random")) {
missingFns <- list(
mean = function(x) {
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-ggparcoord.R
Expand Up @@ -227,6 +227,17 @@ test_that("order", {
}
})

test_that("missing and order(anyClass)", {
ds2 <- diamonds.samp
ds2[3, 1] <- NA
missing_options <- c("exclude", "mean", "median", "min10", "random")

for (missing in missing_options) {
p <- ggparcoord(data = ds2, columns = c(1, 5:10), groupColumn = 2, missing = missing, order = "anyClass")
}
expect_true(TRUE)
})

test_that("basic", {
# no color supplied
p <- ggparcoord(data = diamonds.samp, columns = c(1, 5:10))
Expand Down