[R] getting rank order

Jay Pfaffman pfaffman at relaxpc.com
Fri Jan 25 00:35:14 CET 2002


I'm doing a study where people place a deck of cards in a certain
order.  It's sufficient to assume that their colors & each has a
number (it's actually about attributes of hobbies).  I'd like to look
for patterns in how they've arranged the deck.  For each subject I
have a list like 3,5,2,4,1, indicating that (s)he chose 3 first, then
5, then 2. . . .

I think what I first need to do is to make a variable for each card
with the rank given to each card, so the above list should be
transformed to something like

card1 card2 card3 card4 card5
  5     3     1     4     2

I've RTFMed on sort and rank.  I can't find an elegant solution in
either a spreadsheet or R.  I'm about to give up and do it by hand.

I thought that something like

   for (i in 1:25) ranks [1,as.integer(motivations[1,i])] <- i

might do it (and I'd add another loop to replace the 1's above), but
I've been unsuccessful.

Anyway, solutions to that problem are welcome, as are suggestions
about how to start looking at those data once I've done that.

Thanks.

P.S.  I asked some weeks ago for pointers to some "R cookbooks."
Several people pointed out the "user contributed" documents.  I'm not
sure how I missed them, but I did.  They've been quite helpful.  Also,
I was able to find a copy of MASS in the library (not sure why I
didn't think to look there sooner).  I'll soon break down and buy it.
Thanks to all those who helped.

-- 
Jay Pfaffman                           pfaffman at relaxpc.com
+1-415-821-7507 (H)                    +1-415-810-2238 (M)
http://relax.ltc.vanderbilt.edu/~pfaffman/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list