Is there a way to do a Mann-Whitney/Wilcoxon rank sum test on data in this format?

Yes. Calculating the test statistic is simple. Your biggest problem will be the heavy ties.

I have been using the wilcox.test function, but it requires each observation to be listed individually, rather than totalled;

There are several ways to get the data into a form that wilcox.test will take. Here's one:

```
exper <- read.table(stdin(),header=TRUE)
TreatA TreatB TreatC
Poor 2 2 1
Fair 1 1 1
Moder 1 2 0
Good 0 0 2
Exc 1 0 1
# at this point exper looks like your data
# make it an actual table:
exper <- as.matrix(exper)
class(exper) <- "table"
# convert it:
expertmp <- as.data.frame(exper)
# convert the counts to repetitions:
errle <- list(lengths=expertmp$Freq,values=1:length(expertmp$Freq))
class(errle) <- "rle"
experaw <- expertmp[inverse.rle(errle),1:2]
#need to make it an ordered factor.
experaw$Var1 <- ordered(experaw$Var1)
```

At this point, the data is in a form you can use. You can use `rep`

rather than `inverse.rle`

(and it's probably a bit shorter that way) to expand counts to repetitions.

e.g., you can do this:

```
kruskal.test(as.numeric(Var1)~Var2,experaw)
```

or this:

```
wilcox.test(as.numeric(Var1)~Var2,experaw[experaw$Var2!="TreatC",])
```

but (as R warns you in the second case) the p-value with ties is not exact. And unfortunately ties are heavy. You could do a permutation test (/randomization test) and get a "simulated" p-value, which will effectively be exact at a sufficiently large number of resamples.

However, since your observations-per-sample are pretty large, you should be able to get away with a normal approximation with the variance adjusted for ties. There's sufficient information in say Conover's *Practical Nonparametric Statistics* to do this for oneself.

## Best Answer

First of all it might be useful to remember that Mann-Whitney test is also called Wilcoxon rank-sum test. Since it is the same test there is no need to explain the difference ;) A good answer to the common question about the difference between W statistic and U statistic is given here: Is the W statistic output by wilcox.test() in R the same as the U statistic?

Mann-Whitney/Wilcoxon rank-sum test (later MWW test) is defined in

Rthrough functionwilcox.test(withpaired=FALSE) which uses [dprq]wilcox functions.However, people sometimes mistake MWW with Wilcoxon signed-rank test.

The difference comes from the assumptions. In the MWW test you are interested in the difference between two

independentpopulations (null hypothesis: the same, alternative: there is a difference) while in Wilcoxon signed-rank test you are interested in testing the same hypothesis but withpaired/matchedsamples.For example, the Wilcoxon signed-rank test would be used if you had replicates (repeated) measurements between different time points/plates/... since it is the same sample but measured in different time/on different plates.

Wilcoxon signed-rank test is defined in

Rthroughwilcox.testfunction (withpaired=TRUE) which uses [dprq]signrank functions.Another implementation of MWW/Wilcoxon signed-rank test can be found in the

coinpackage throughwilcox_testfunction.