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

GGally alter the data types when passed to the plotting functions #436

Open
kalashnov opened this issue Apr 4, 2022 · 0 comments
Open

Comments

@kalashnov
Copy link

GGally allows the user to pass a function defining his own plot for a cell with arguments like upper, lower, etc. (the examples for ggpairs). The dataset passed to a user-defined function is changed, e.g. the character columns are changed to factor columns.

This causes unexpected bugs, which are hard to catch if you are not informed about this behaviour. Moreover, this behaviour is strange, because a user can have a reason to use character instead of factor and casting the data back, when inside the function looks like a hack.

library(GGally)

some_f <- function(data, mapping) {
  print(class(data$color))
}

data <- data.frame(a=1:10, b=1:10, c=1:10,
                   color=rep(c('red', 'blue'), 5),
                   stringsAsFactors=FALSE)

class(data$color)
#> [1] "character"
ggpairs(data, columns=1:3, upper=list(continuous=some_f))
#> [1] "factor"
#> [1] "factor"
#> [1] "factor"
@kalashnov kalashnov changed the title GGally functions alter the data types when passed to the plotting functions GGally alter the data types when passed to the plotting functions Apr 4, 2022
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