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

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

Open
kosalk opened this issue Sep 7, 2022 · 1 comment
Assignees
Labels
type: bug Existing features not working as expected
Milestone

Comments

@kosalk
Copy link

kosalk commented Sep 7, 2022

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:

  • the number of continuous variables is such that there remains 1 plot in the last page; e.g. 217 continuous variables for a 3x3 page => 24 pages with 9 plots each + 1 page with 1 plot
  • the "by" parameter is among the continuous variables, it is removed from dt2, so only N-1 variables are plotted => the last page is empty!
  • when trying to plot the last page, the error is thrown.

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
Copy link
Owner

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)

@boxuancui boxuancui self-assigned this Sep 7, 2022
@boxuancui boxuancui added the type: bug Existing features not working as expected label Sep 7, 2022
@boxuancui boxuancui added this to the v0.9.0 milestone Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants