I am trying to observe a change between observation points before
and after
and compare the result within two groups, that is the variable condition
. I tried this code:
Data %>% select(condition, before, after) %>%
tbl_summary(by=condition) %>%
add_p(test=everything()~"paired.wilcox.test")
Appears, I don't get the p-value I am looking for. I got this error, and I don't understand what it means. Can you help me?
There was an error in 'add_p()/add_difference()' for variable 'before', p-value omitted:
Error: 'before': There may only be one observation per `group=` per `by=` level.
There was an error in 'add_p()/add_difference()' for variable 'after', p-value omitted:
Error: 'after': There may only be one observation per `group=` per `by=` level.
My data
structure(list(condition = c(2, 2, 1, 2, 2, 1, 1, 2, 2, 2, 1,
2, 2, 1, 2, 1, 2, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 1,
2, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 1, 2, 2,
1, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 2, 1,
2, 1), before= c(13, 7, 18, 18, 15, 5, 14, 5, 3, 6,
18, 7, 5, 11, 6, 3, NA, 3, 11, 8, 10, 3, 7, 7, 12, 3, 5, 8, 4,
9, 15, 9, 3, 16, 3, 3, 11, 3, 11, 8, 14, 21, 21, 17, 9, 3, 18,
15, 6, 6, 12, 9, 15, 5, 13, 7, 6, 7, 9, 11, 21, 12, 7, 12, 6,
21, 15, 21, 16, 12, 7, 18, 12, 20, 3, 10), after= c(15,
3, 6, 18, 14, 15, 6, NA, 6, 3, 18, NA, 3, 15, NA, 15, 11, NA,
10, 9, NA, 6, 6, 12, 3, NA, NA, 11, 9, 15, 21, 21, 6, 15, 9,
16, 9, 11, 14, 13, 5, NA, 3, 10, NA, 3, 18, 12, NA, NA, 8, 11,
14, NA, 13, NA, NA, 10, 6, 5, 15, 11, 12, NA, 5, NA, 15, 21,
11, NA, 3, NA, 12, NA, 17, 15)), class = c("rowwise_df", "tbl_df",
"tbl", "data.frame"), row.names = c(NA, -76L), groups = structure(list(
.rows = structure(list(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L,
10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L,
32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L,
65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L,
76L), ptype = integer(0), class = c("vctrs_list_of",
"vctrs_vctr", "list"))), row.names = c(NA, -76L), class = c("tbl_df",
"tbl", "data.frame")))