# How to rank data in R?

I'll use equality of variance test by Mann-Whitney rank sum test but I can't define order for data

x <- c(76.375, 75.125, 77, 77, 77, 76.375, 77, 76.375)
y <- c(76.375, 75.75, 76.375, 76.375, 76.375, 75.75, 77, 76.375)

x1=75.125
x2=75.750
x2=75.750
x1=76.375
x1=76.375
x1=76.375
x2=76.375
x2=76.375
x2=76.375
x2=76.375
x2=76.375
x1=77.000
x1=77.000
x1=77.000
x1=77.000
x2=77.000


I want to rank newdata giving

(x1=75.125 is order1),
(x2=77.000 is order2),
(x1=77.000 is order3),
(x2=75.750 is order4),
(x2=75.750 is order5),
(x1=77.000 is order6),
(x1=77.000 is order7),
(x1=76.375 is order8),
.
.
.

• Please don't post a slightly edited version of a question you already asked. Fix the question you asked before. Please also read the help/on-topic, where it discusses "Programming". If you keep posting essentially the same questions -- all of which will simply end up the same way -- you will eventually cause the system to prevent you from asking any questions at all. Nov 11, 2015 at 11:52
• If you want to manually order the data in a specific way, JonB already gave you the answer. However from your question it seems you need to rank the data for the Mann-Whitney test. For that you can use the function rank. But this is different from what you are suggesting in the example (e.g., the rank of the observation for which you set order = 8, (x1=76.375 is order8), is clearly not 8), so if that is the case please correct your question. You can make the Mann-Whitney test with the function wilcox.test. Type ?wilcox.test and read the Details section. Nov 11, 2015 at 12:47
• @Glen_b: The question you closed this as a duplicate of has been deleted. Presumably, this question should be either reopened or also deleted. Mar 8, 2018 at 1:41
• @ilmari Thanks, repoened. For future reference, you can flag situations like this one. If this were posted now, it would be more likely to be considered off topic that it was a few years ago, but the post it was closed as a duplicate of was old enough for the standard of what was felt to be on topic to be somwhat different (it's for that reason I considered it grandfathered in, in turn). Mar 8, 2018 at 7:32

neworder <- c(1,20,3,4,2,5)

newdata <- data[neworder]