Is the W statistic output by wilcox.test() in R the same as the U statistic? I've recently been reading about the Mann-Whitney U test. It turns out that to carry out this test in R you actually need to run a Wilcoxon test!
My question: is the W statistic of wilcox.test in R identical to the U statistic?
 A: Wilcoxon is generally credited with being the original inventor of the test*, though Mann and Whitney's approach was a great stride forward, and they extended the cases for which the statistic was tabulated. My preference is to refer to the test as the Wilcoxon-Mann-Whitney, to recognize both contributions (Mann-Whitney-Wilcoxon is also seen; I don't mind that either).
* However, the actual picture is a little more cloudy, with several other authors also coming up with the same or similar statistics about this time or earlier, or in some cases making contributions that are closely connected to the test. At least some of the credit should go elsewhere.
The Wilcoxon test and the Mann-Whitney U test are equivalent (and the help states that they are) in that they always reject the same cases under the same circumstances; at most their test statistics will only differ by a shift (and in some cases, just possibly a sign change).
The Wilcoxon test is defined in more than one way in the literature (and that ambiguity dates back to the original tabulation of the test statistic, more on than in a moment), so one must take care with which Wilcoxon test is being discussed.
The two most common forms of definition are discussed in this pair of posts:
Wilcoxon rank sum test in R
Different ways to calculate the test statistic for the Wilcoxon rank sum test
To address what, specifically, happens in R:
The statistic used by wilcox.test in R is defined in the help (?wilcox.test), and the question of the relationship to the Mann-Whitney U statistic is explained there:

The literature is not unanimous about the definitions of the Wilcoxon rank sum and Mann-Whitney tests
The two most common definitions correspond to the sum of the ranks of the first sample with the minimum value subtracted or not: R subtracts and S-PLUS does not, giving a value which is larger by m(m+1)/2 for a first sample of size m. (It seems Wilcoxon's original paper used the unadjusted sum of the ranks but subsequent tables subtracted the minimum.)
R's value can also be computed as the number of all pairs (x[i], y[j]) for which y[j] is not greater than x[i], the most common definition of the Mann-Whitney test.

This last sentence completely answers that aspect of your question - the version of W that R puts out* is also the value of U.
* The sum of the ranks in sample 1, minus the smallest value it can take (i.e. minus $\frac{n_1(n_1+1)}{2}$).
A: Both the Wilcoxon rank sum test and the Mann-Whitney test are the non-parametric equivalents of the independent t-test. In some cases the version of W that R gives, is also the valua of U. But not in all cases.
When you use: wilcox.test(df$var1 ~ df$var2, paired=FALSE) the given W is the same as U. So you may report it as the Mann-Whitney U statistic.
However when you use: wilcox.test(df$var1 ~ df$var2, paired=TRUE), you are actually performing a Wilcoxon signed rank test. The Wilcoxon signed rank test is the equivalent of the dependent t-test.
Source: "Dicovering statistics using R" by Andy Field (2013)
A: Note however, that the code: 
wilcox.test(df$var1 ~ df$var2, paired=FALSE) (using '~')
will produce a different W statistic than a:
wilcox.test(df$var1, df$var2, paired=FALSE) (using ',')
