Different ways of performing the Wilcoxon rank sum test and the interpretation of the resulting W-statistic What is the practical difference between wilcox.test(x,y, paired=F) and wilcox.test(x~y, paired=F) (i.e. using comma vs. tilde sign) in R, and how to interpret the resulting W-statistic? This should be the same statistical test, but the two methods produce different results.
I have a data frame with 24 rows, each containing information about the sex 
and the length of an individual:
mydata<-structure(list(ID = 1:24, Sex = structure(c(2L, 2L, 2L, 2L, 2L, 
1L, 2L, 1L, 2L, 1L,1L, 2L, 1L, 1L, 2L,2L, 2L, 2L, 1L, 1L,2L, 2L, 2L, 2L), .Label = c("F", "M"), class = "factor"),Length = c(63.8,79.6, 58, 140, 293, 28.6, 147, 31.3, 33.2, 4.55, 16.4, 19.5, 26.4, 3.34, 29.3, 42.9, 55.6, 122, 30.3, 48.4, 130, 64.7, 93.3, 76.1)), .Names = c("ID", "Sex", "Length"), class = "data.frame", row.names = c(NA, -24L))
I want to explore differences in length between the two sexes using Mann-Whitney U test.
Version 1:
wilcox.test(mydata$Length[mydata$Sex == 'M'], mydata$Length[mydata$Sex == 'F'], paired=F)
        Wilcoxon rank sum test

data:  mydata$Length[mydata$Sex == "M"] and mydata$Length[mydata$Sex == "F"]
W = 118, p-value = 0.0003698
alternative hypothesis: true location shift is not equal to 0

Version 2:
wilcox.test(mydata$Length ~ mydata$Sex, paired=F)
        Wilcoxon rank sum test

data:  mydata$Length by mydata$Sex
W = 10, p-value = 0.0003698
alternative hypothesis: true location shift is not equal to 0

They both give me the same P-value, but drastically different W statistics (118 vs. 10).
I can't see why this is, or know which one to use for inferences or reporting. Should I not expect to get the same answer from both methods?
And how would one go about interpreting the resulting W-statistics?
 A: The Mann-Whitney U statistic counts 1 every time an observation in one sample is less than an observation in the other sample, across all cross-sample pairs of observations. However, it's arbitrary which sample is regarded as the first sample and which one is regarded as the second sample -- if you swap them, the sum of the statistics you got each time will be the total number of pairs ($U_1+U_2=n_1 n_2$) 
In your case that's 8 x 16 = 128 pairs, so if you swap the two samples and recalculate, the statistic will change from 10 to 128-10 = 118. Either way this is the same distance from the expected value under the null, $E(U) = n_1 n_2/2=64$.

If you think in terms of the Wilcoxon rank sum statistic W (the sum of ranks in sample 1) there's also two possible values depending on which one you call sample 1. However, again they're related to each other in a similar way to the Mann-Whitney statistics above, and indeed they're also related to the Mann-Whitney statistics themselves (by a simple shift).
(R calls its statistic W but subtracts the smallest possible sum of ranks, making it exactly equal to the U statistic.)
The same thing happens when you do a t-test -- you get a different statistic when you look at $\bar{X}-\bar{Y}$ than when you look at $\bar{Y}-\bar{X}$ -- again again they're equally far from what's expected under the null case (in this case, the null case will have expected statistic 0.
