I want to apply pairwise.wilcox.test for multiple independent variables at a time and then want to have the output in long format. For a particular Wavelength,
A bit verbose and Im sure it could be made more efficient:
library(tidyverse)
library(broom)
res <-
tbl_df(df)%>%
pivot_longer(cols = -Class, names_to = "Wavelengths", values_to = "value") %>%
group_by(Wavelengths) %>%
summarise(pw_wt = list(pairwise.wilcox.test(value,as.factor(Class),
p.adjust.method = "bonf")$p.value)) %>%
ungroup() %>%
mutate(pw_wt_t = map(pw_wt, broom::tidy)) %>%
unnest(pw_wt_t)