Skip to content

Commit

Permalink
fix: ggparcoord anyClass ordering with missing values in data
Browse files Browse the repository at this point in the history
  • Loading branch information
92amartins committed Apr 25, 2024
1 parent 1f58feb commit 7d4142d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 7d4142d

Please sign in to comment.