Wilcoxon-Mann-Whitney Test using R

 

Very simple code for Wilcoxon-Mann-Whitney test in R:

> mpg$drv_front <- NA
> mpg[which(mpg$drv == 'f'), ]$drv_front <- 1
> mpg[which(mpg$drv != 'f'), ]$drv_front <- 0
> attach(mpg)
> wilcox.test(hwy ~ drv_front)
Wilcoxon rank sum test with continuity correction

data: hwy by drv_front
W = 915.5, p-value < 2.2e-16
alternative hypothesis: true location shift is not equal to 0

 

 

 

See Also:

Do the same test in SAS

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *