Rank per row over multiple columns in R -


i'm using r analysis of masterthesis. unfortunately, got stuck problem:

i compute new variable calculates rank of 1 variable per row within many variables.

example:

v1    v2    v3   newvariable_v1 newvariable_v2 newvariable_v3 11    21    35   3              2               1 22    12    66   2              3               1 44    22    12   1              2               3 

does know how that? i'd glad help.

you're looking rank. decreasing order, first negate data.frame.

data.frame(d, t(apply(-d, 1, rank, ties.method='min'))) #   v1 v2 v3 v1.1 v2.1 v3.1 # 1 11 21 35    3    2    1 # 2 22 12 66    2    3    1 # 3 44 22 12    1    2    3 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -