I really cannot find anything usefull online for this problem. I've got dataset where one variable has been measured on 4 different occasion (CRP1, CRP4, CRP7, CRP10) and I've run pairwise Wilcoxon test to compare CRP drop trend between 2 groups. I've also made ggplot to show the significant p values.
Now I want to present my p values through the tbl_summary() function, but it seems that I cannot accomplish that. Wilcoxon test that I've run to get my p values was performed on the long format of my dataset.
structure(list(LEK = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L), levels = c("Lek +", "Lek -"), class = "factor", label = "Terapija"),
CRP1 = c(103.9, 155.6, 102.2, 89.2, 32.3, 258.8, 58.5, 196.7,
89.3, 175, 170.9, 204.3, 82.2, 196.9, 220.4, 92, 37.1, 34,
223.6, 261.5, 82, 37.4, 112, 81.8, 47.5, 70.1, 137.2, 84.7,
151.9, 159.8, 149.7, 140, 37.9, 143, 130.6, 110.7, 112.9,
48.1, 115.5, 43, 102.1, 35.9, 120.3, 40.9, 169.9, 105.6,
90, 139.6, 246.4, 146.9, 13.9, 60.9, 123.1, 187.3, 23.6,
112.9, 17.5, 9.9, 120.4, 103.7, 12.4, 96.7, 144.9, 54.1,
186.6, 143.6, 30.6, 41.8, 146.4, 94.9, 144.2, 98.5, 63.3,
137.1, 81.1, 14.1, 117.3, 55.4, 92.7, 40.3, 189.7, 77.2,
36.7, 73.7, 19.8, 39.1, 119, 60.6, 110.6, 63.2, 135.1, 131.6,
206.9, 117.1, 92.6, 123.3, 297, 153.3, 210.4, 116.1, 59.3,
177.3, 37.1, 101.2, 87.8, 138.6, 88.9, 95.6, 71.6, 81.1,
394.3, 4.8, 36.4, 229.3, 108.4, 404.1, 259.5, 292.9, 134.1,
127.5, 33.2, 29.2, 346.3, 116, 302), CRP4 = c(21, 74.7, 26.3,
48.1, 23.7, 86, 15.1, 33.7, 29.3, 16.9, 115, 79.5, 48, 58.5,
332.2, 153, 28.2, 11.6, 94.4, 50.2, 85.8, 48.7, 25, 14.3,
150.2, 145.5, 64.2, 28, 143.9, 57.6, 11, 132.9, 96.9, 44.4,
200.2, 45.2, 7.4, 95, 38.1, 12.5, 29.2, 6.8, 104.5, 15.3,
32.9, 26.5, 25, 49.7, 142.5, 37.5, 6.4, 32.1, 44.3, 70.9,
22.2, 72.2, 40.2, 3.5, 9.3, 72.5, 36, 17.9, 161.8, 18.5,
48.2, 198.7, 52.8, 77.6, 93.7, 162.7, 45.6, 206.4, 269.9,
21.1, 14.1, 22, 97.3, 52.2, 61, 34.8, 45.9, 43.6, 16.4, 203.6,
35.5, 28.1, 87.7, 23.2, 35.8, 44.2, 104.4, 83.7, 49.2, 23.5,
21.7, 118.6, 78.8, 101.6, 162.5, 23.9, 21.6, 109.3, 62.8,
146.1, 84.6, 57.6, 225.3, 143.4, 104.1, 29.7, 319.5, 104.5,
110.2, 120.3, 99.7, 172.1, 293.3, 262.9, 190.2, 82.4, 129.1,
5.5, 75.2, 36.8, 69.2), CRP7 = c(2.8, 110.8, 63.4, 51.3,
20.8, 27.8, 2.2, 194.6, 24.2, 8.3, 70.7, 93.3, 6.4, 38.3,
188.3, 75.1, 49.4, 5, 107.2, 37.8, 246.3, 26.4, 4.2, 4.3,
28.2, 22.4, 9.1, 195.9, 150.7, 67.4, 8.6, 283.6, 63.1, 100.9,
82.7, 9.9, 7.6, 207, 6.7, 9.2, 245.8, 42.5, 179.8, 12.3,
4.2, 6, 8.8, 5.9, 28.8, 27, 3.5, 24.8, 14.4, 55.5, 3.9, 106.7,
49.8, 11.1, 3.77, 68, 52.4, 32.7, 223.6, 12.3, 117.7, 66.1,
184.5, 29.3, 174.7, 119.3, 80.2, 87.9, 135.6, 22.8, 12.2,
82.7, 9.1, 32.3, 21.3, 82, 12.1, 37.8, 48.2, 56.6, 6.5, 37,
112.9, 11, 142.8, 18.4, 71.5, 91.1, 8.9, 7, 166.7, 55.4,
123.8, 46.8, 64.5, 5, 10.5, 201.7, 188.5, 198.7, 271.8, 276,
181.8, 190.2, 164.6, 65.1, 322.8, 61.9, 195.7, 225.5, 66.6,
119.4, 268.5, 350.3, 223.2, 161, 34.3, 22.4, 243.8, 62, 39.8
), CRP10 = c(NA, NA, NA, 184.3, 4.4, 7.7, NA, NA, 1.2, 1,
1, 12.3, 2.5, 62.2, 43.4, 57.7, 100.3, 15.6, 4.2, 11.5, NA,
8.3, 1, 1.3, 11.9, 63, NA, 71.4, 60.3, 54.6, 6.7, 313.8,
37, NA, 123.7, 2.5, 2.2, NA, 252.4, 9.7, NA, 82.2, 230.8,
5.8, 1, NA, 3.9, 1, 6.9, 34.7, 2.6, NA, 15.2, 6.4, 6.1, NA,
214.7, NA, 22.5, 86.5, 13.9, 41, 246.5, 9, 26.5, 270, 270.8,
7.6, 65.7, 90.5, 202.3, 288.6, 464, 92.1, 19.7, 307.5, 10.6,
71.2, 80.6, 159.8, 4.1, 103.7, 80.6, 324, 9.5, 6.3, 9.6,
4.1, 151.5, 20.3, 63.6, 311, 2.8, 52.8, 62.3, 13.5, 248,
72.2, 83.5, 13.8, 37.8, 179, 72.4, 206.4, 76.4, 210.6, 69.5,
87.9, 303.3, 59.1, 174.5, 211, 211.2, 240.8, 38.6, 109.6,
251.7, 328.9, 87.1, 113.5, 48.9, 16.4, 277, 25.7, 122)), row.names = c(NA,
-125L), class = c("tbl_df", "tbl", "data.frame"))
LongCRP <- Statistika %>%
select(LEK, CRP1, CRP4, CRP7, CRP10) %>%
filter(complete.cases(.)) %>%
gather("Vreme", "CRP", CRP1, CRP4, CRP7, CRP10) %>%
mutate(Vreme = factor(Vreme, levels = c("CRP1", "CRP4", "CRP7", "CRP10"))) #Long format
pairwise.wilcox.CRP <- LongCRP %>%
group_by(LEK) %>%
pairwise_wilcox_test(
CRP ~ Vreme
)
pairwise.wilcox.CRP <- pairwise.wilcox.CRP %>% add_xy_position(x = "LEK")
ggplot(LongCRP, aes(x = LEK, y = CRP, color = Vreme)) +
geom_boxplot() +
stat_pvalue_manual(pairwise.wilcox.CRP, label = "p.adj.signif",
step.increase = 0.03,
bracket.nudge.y = 20) +
theme_minimal() +
ggtitle("Trend opadanja vrednosti CRP-a kod lečenih i nelečenih bolesnika") +
labs(x = "Terapija") +
scale_color_discrete(name = "Vreme\nmerenja CRP-a")
Now I know that I can extract p values from my ggplot graph, but I would really want to use tbl_summary() for this.
Thank you for the help!