Can someone explain the nuance in the wilcox.test function? This is from a homework assignment for my grad stats class. First I generate a dataset:
       set.seed(13)
       d2 <- cbind(rnorm(11, 142, 21), rnorm(11, 123, 23))

Then perform a wilcox test on the data:
        wilcox.test(d2, alternative="two.sided", conf.level = 0.95)

Then the resulting test statistic and P value are 253 and 4.78x10^-7 respectively
However, when I split up the data into two separate vectors and run a wilcoxon test specifying that the data is paired, I get very different results:
        d2A<- d2[,1] ; d2B<- d2[,2]
        wilcox.test(d2A, d2B, paired=TRUE, alternative="two.sided", conf.level = 0.95)

The resulting test statistic and P value are 54 and 0.06738 respectively
I am wondering what the difference is between these two scenarios. They are both willcoxon signed-rank tests, with the same assumptions and the same datapoints, yet the results are so different.
 A: Ok. Both of these ask for a signed-rank test (a one-sample test) --  the first one because obviously; the second one because of paired=TRUE
However, the signed-rank test has a parameter. To quote the help page for wilcox.test

If only x is given, or if both x and y are given and paired is TRUE, a
Wilcoxon signed rank test of the null that the distribution of x (in
the one sample case) or of x - y (in the paired two sample case) is
symmetric about mu is performed.

You didn't specify mu, so it takes the default value 0.
The first test is of the null  hypothesis that the 26 observations are centered at zero (to be precise,  that the  median pairwise mean is zero).   This is  obviously false,  since they're  actually centered around 11.
The second test is of the null  hypothesis that the 13 paired difference are centered at zero.  This is true, since the distribution of the difference is $N(0,21^2+23^2)$
So, you  get a very small $p$-value for the first test and a moderate $p$-value for  the second  one.  If you repeat with different random seeds,  the  first one is reliably small, and the second one is usually larger than the 0.06 you quote.
