I got a list of p-values, obtained from two large datasets, by using the wilcox.test()
function.
Since there's a multiple comparisons, I have to do adjustment of the p-values.
Problem is I just don't get how the p.adjust()
function works.
Could someone please tell me step by step what to do, so I get adjusted p-values for all my known p-values?
I simply reproduce your data and bring this simple function:
dat <- data.frame(
value=c(4409, 55.5, 3951.5),
p.value=c(2.766e-15, 0.04606, 1.545e-15)
)
This is the simple function to get adjusted p-value:
getAdjustPval <- function(df, pAdjustMethod="BH", ...) {
if(is.null(df$p.value)) {
stop("p-value is required")
} else {
p <- df$p.value
df$adjust.pvalue <- p.adjust(p, method = pAdjustMethod)
df
}
}
you'll get this:
value p.value adjust.pvalue
1 4409.0 2.766e-15 4.149e-15
2 55.5 4.606e-02 4.606e-02
3 3951.5 1.545e-15 4.149e-15