0
$\begingroup$

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),
.
.
.
$\endgroup$
4
  • 2
    $\begingroup$ 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. $\endgroup$
    – Glen_b
    Nov 11, 2015 at 11:52
  • 2
    $\begingroup$ 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. $\endgroup$
    – matteo
    Nov 11, 2015 at 12:47
  • $\begingroup$ @Glen_b: The question you closed this as a duplicate of has been deleted. Presumably, this question should be either reopened or also deleted. $\endgroup$ Mar 8, 2018 at 1:41
  • $\begingroup$ @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). $\endgroup$
    – Glen_b
    Mar 8, 2018 at 7:32

1 Answer 1

1
$\begingroup$

You can specify the order manually if you wish:

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

This argument manually specifies the order you want.

newdata <- data[neworder]

And now newdata is ordered as you specified.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.