Skip to content
Prev 343220 / 398513 Next

Turn Rank Ordering Into Numerical Scores By Transposing A Data Frame

There is probably an easier way to do this, but
+  "green", "yellow", NA), 4))))
rank1  rank2  rank3 rank4
1   <NA> yellow    red  blue
2 yellow  green   <NA>   red
3 yellow  green   blue  <NA>
4   <NA>   blue yellow green
5   <NA>    red   blue green
6   <NA>    red  green  blue
blue green red yellow
1    4     0   3      2
2    0     2   4      1
3    3     2   0      1
4    2     4   0      3
5    3     4   2      0
6    4     3   2      0

David C

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Simon Kiss
Sent: Friday, August 15, 2014 3:58 PM
To: r-help at r-project.org
Subject: Re: [R] Turn Rank Ordering Into Numerical Scores By Transposing A Data Frame


Both the suggestions I got work very well, but what I didn't realize is that NA values would cause serious problems.  Where there is a missing value, using the argument na.last=NA to order just returns the the order of the factor levels, but excludes the missing values, but I have no idea where those occur in the or rather which of those variables were actually missing.  
Have I explained this problem sufficiently? 
I didn't think it would cause such a problem so I didn't include it in the original problem definition.
Yours, Simon
On Jul 25, 2014, at 4:58 PM, David L Carlson <dcarlson at tamu.edu> wrote:

            
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.