Note that there are some explanatory texts on larger screens.

plurals
  1. POrank sum score calculation on a data.frame
    text
    copied!<p>I have a data.frame that looks like this: </p> <blockquote> <pre><code> Name1 Name2 Name3 1 1 1 -1 -1 1 1 -1 1 1 -1 1 -1 -1 1 </code></pre> </blockquote> <p>I would like to perform a sort of rank-sum test for each column so that: </p> <p>starting from the first element of each column (so for each list of my data.frame) if the second element is equal to the first (for ex: 1 and 1) the score will be increased by an unit because they are equals, otherwise the score will be decreased by an unity (because they are unequals, for ex: 1 and -1). </p> <p>Ex: column "Name1"<br> first element = 1 : score = 1 (starting position)<br> second element = -1: score = 0 (1 unit is removed from the previous score (1) because 1 != -1)<br> third element = 1 : score = 1 (you are initializing the score to 1. Every time you initialize, the score is +1).<br> fourth element = 1 : score = 2 ( previous score 1 plus 1 unit because the third and the fourth elements are equals)<br> fifth element = -1: score = 1 (previous score 2 - 1 unit because fourth element != fifth element). </p> <p>column "Name2"<br> first element = 1 : score = 1 (starting position)<br> second element = -1: score = 0 (1 unit is removed from the previous score (1) because 1 != -1)<br> third element = -1: score = 1 (you are reinitializing the score)<br> fourth element = -1: score = 2 (third element is equal to the fourth so the previous score will be increased by 1 unit)<br> fifth element = -1: score = 3 (fourth element is equal to the fifth one so the previous score, so 2, will be increased by 1 unit) </p> <p>So the counter will increase or decrease the score of a number == 1 if the element in the ranking is equal or different by the previous one and it will be initialized to 1 every time it goes to 0. </p> <p>The final goal is to give an higher score to the equals and consecutive elements in the rank respect to the random ones.</p> <p>Can anyone help me please? </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload