boxuancui / DataExplorer

Automate Data Exploration and Treatment
http://boxuancui.github.io/DataExplorer/
Other
512 stars 88 forks source link

plot_qq throws Error in `combine_vars()`: ! Faceting variables must have at least one value #172

Open kosalk opened 2 years ago

kosalk commented 2 years ago

When calling plot_qq with a "by" parameter, an error is thrown: Error in combine_vars(): ! Faceting variables must have at least one value

While debugging, it appears that error happens in this precise case:

Solution: In plot_qq, check that "by" is not among the continuous variables: nplots <- ncol(continuous) if (!is.null(by) && by %in% names(split_obj$continuous)) nplots <- nplots - 1 layout <- .getPageLayout(nrow, ncol, nplots)

boxuancui commented 2 years ago

Can reproduce with a simpler example:

library(DataExplorer)
library(data.table)

test <- data.table(sapply(seq.int(3L), function(x) rnorm(100L)))
plot_qq(test, by = "V1", nrow = 1L, ncol = 2L)

As OP mentioned, variable in by is getting through and being removed at the same time.

Plot is still being generated, but with a blank page and an error message. To suppress the error, do:

try(plot_qq(test, by = "V1", nrow = 1L, ncol = 2L), silent = TRUE)