imbi-heidelberg / DescrTab2

This package provides functions to create descriptive statistics tables for continuous and categorical variables.
https://imbi-heidelberg.github.io/DescrTab2/
9 stars 7 forks source link

Wilcoxon paired two-sample test does not handle improperly matched data correctly #15

Closed jan-imbi closed 2 years ago

jan-imbi commented 2 years ago
good_idx <- names(table(id)[table(id) == 2])
if (!all(id %in% good_idx)) {
warning("Removed paired observations with missings.")
}
tibl <- tibble(
var = var,
group = group,
id = id
)
tibl %<>% filter(id %in% good_idx)
level1 <- levels(group)[1]
level2 <- levels(group)[2]
x <-
tibl %>%
filter(group == level1) %>%
arrange(id) %>%
pull(var)
y <-
tibl %>%
filter(group == level2) %>%
arrange(id) %>%
pull(var)

Warning message should read "Data improperly matched". Also need to check table(id, group) < 2 I think.

jan-imbi commented 2 years ago

fixed in new version