-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
The error message says that the by variable must have two levels (which it does), so the error we're returning isn't great.
I suspect this is because we first remove all the NA values, which then does create a data frame where the by variable does indeed have fewer than 2 levels.
Related, the prop.test() doesn't require 2 levels for the stratifying variable, and we should generalize the the function to allow for a single group and 2 or more groups. The returned statistics will depend on the number of levels, so we'll need to account for that as well.
mtcars |>
dplyr::mutate(mpg = NA) |>
cardx::ard_stats_prop_test(
variable = mpg,
by = am
) |>
cards::print_ard_conditions()
#> The following errors were returned during `print_ard_conditions()`:
#> ✖ For variable `mpg` (`am`) and "estimate", "estimate1", "estimate2",
#> "statistic", "p.value", "parameter", "conf.low", "conf.high", "method",
#> "alternative", "p", "conf.level", and "correct" statistics: The `by` column
#> must have exactly 2 levels. The levels areCreated on 2025-05-03 with reprex v2.1.1
Metadata
Metadata
Assignees
Labels
No labels