Not all row groups are identical error in qwraps2

102 Views Asked by At

I could not debug this error. I am just doing a simple grouping using the same command in the vignette like.

our_summary1 <-
  list("Miles Per Gallon" =
       list("min"       = ~ min(mpg),
            "max"       = ~ max(mpg),
            "mean (sd)" = ~ qwraps2::mean_sd(mpg)),
       "Displacement" =
       list("min"       = ~ min(disp),
            "median"    = ~ median(disp),
            "max"       = ~ max(disp),
            "mean (sd)" = ~ qwraps2::mean_sd(disp)),
       "Weight (1000 lbs)" =
       list("min"       = ~ min(wt),
            "max"       = ~ max(wt),
            "mean (sd)" = ~ qwraps2::mean_sd(wt)),
       "Forward Gears" =
       list("Three" = ~ qwraps2::n_perc0(gear == 3),
            "Four"  = ~ qwraps2::n_perc0(gear == 4),
            "Five"  = ~ qwraps2::n_perc0(gear == 5))
       )
by_cyl <- summary_table(dplyr::group_by(mtcars2, cyl_factor), our_summary1)

However, I get this message

> Error in cbind(deparse.level, ...) : Not all row groups are identical.

The equivalent command to this runs well on my data and looks normal to me.

summary_table(dplyr::group_by(mtcars2, cyl_factor)

But I don't really know what does this error means.

EDIT

Please note that the example here on mtcars is from the vignette and is working 100%. I just don't know what qwrap2 means by this error. I seems certain criteria for grouped data they have.

EDIT2

It seems that this happens when the groups do not match in sizes. Here is a reproducible example.

summary1 <-
  list("Time-To-event" =
       list("min"       = ~ min(x),
            "max"       = ~ max(x),
            "mean (sd)" = ~ qwraps2::mean_sd(x, na_rm =F )),
       "Case Status" =
       list("Dead" = ~ qwraps2::n_perc0(y == 1),
            "Alive/Lost-to-follow"  = ~ qwraps2::n_perc0(y == 0)
            )
       )

dat <-  data.frame(x =c(1:10, rep(NA, 10)) ,y =rep(c(0,1), 10) ,group = c(rep("A", 3), rep("B", 17)))
dat <- dplyr::group_by(dat, group)

by_cyl <- summary_table(dat, summary1)
by_cyl

Note that I have set na_rm = FALSE (default) as I normally one would set it to TRUE. But it seems it was not the culprit anyway.

0

There are 0 best solutions below