Skip to content

Improve messaging in ard_stats_paired_wilcox_test() when a subject has more than two observations #295

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

Open
ddsjoberg opened this issue May 5, 2025 · 0 comments

Comments

@ddsjoberg
Copy link
Collaborator

The warning messaging is being thrown from the pivoting of the table, but we can do better than that!

We should throw an error before we even attempt the pivot.

tmax <- data.frame(Subject = c(1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5), 
                   Treatment = c("T", "R", "T", "R", "R", "T", "R", "T", "T", "R", "T", "R", "R", "T", "R", "T"), 
                   TMAX = c(1.333, 1.667, 0.667, 1.667, 2, 0.667, 2, 2, 1, 1, 2, 1, 0.667, 1, 2, 1))

cardx::ard_stats_paired_wilcox_test(
  data = tmax, by = Treatment, variables = TMAX, id = Subject
) |> 
  dplyr::pull(warning) |> 
  unique()
#> [[1]]
#> [1] "Values from `TMAX` are not uniquely identified; output will contain list-cols.\n• Use `values_fn = list` to suppress this warning.\n• Use `values_fn = {summary_fun}` to summarise duplicates.\n• Use the following dplyr code to identify duplicates.\n  {data} |>\n  dplyr::summarise(n = dplyr::n(), .by = c(Subject, Treatment)) |>\n  dplyr::filter(n > 1L)"

Created on 2025-05-04 with reprex v2.1.1

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