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