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

ggpairs errors out if there is missing data in an ordered factor variable #461

Open
janlimbeck opened this issue Mar 5, 2023 · 0 comments

Comments

@janlimbeck
Copy link

janlimbeck commented Mar 5, 2023

ggpairs seems to error out when applied to a data set that has missing data in an ordered factor variable. ggpairs works fine if there is missing data in an unordered factor variable. Tests were carried out with the latest package versions on cran as of Febuary 1st 2023.

library(GGally)

# example using the iris data set
df <- iris

# ggairs works as expected
ggpairs(df)

# turn species column into an ordered factor
df$Species <- factor(df$Species, levels = levels(df$Species), ordered = T)

# ggairs works still as expected
ggpairs(df)

# simulate missing data
df[1, 'Species'] <- NA

# ggpairs errors out when there is missing data in an ordered factor variable
ggpairs(df)

df <- iris

# simulate missing data
df[1, 'Species'] <- NA

# ggpairs works correctly when there is missing data in an un-ordered factor variable
ggpairs(df)

The error message I am getting is below

Error:
! Can't combine `..1$Species` <factor<fb977>> and `..2$Species` <ordered<fb977>>.
---
Backtrace:
  1. base (local) `<fn>`(x)
 31. ggplot2 (local) `<fn>`(`<vctrs__2>`)
 32. vctrs::vec_ptype2(x, y, x_arg = x_arg, y_arg = y_arg, call = call)
 33. vctrs (local) `<fn>`()
 34. vctrs:::vec_ptype2.factor.ordered(...)
 35. vctrs::vec_default_ptype2(x, y, ...)
 39. vctrs::stop_incompatible_type(...)
 40. vctrs:::stop_incompatible(...)
 41. vctrs:::stop_vctrs(...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant