[R] getting rank order
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Fri Jan 25 00:51:07 CET 2002
Jay Pfaffman <pfaffman at relaxpc.com> writes:
> 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.
Is this what you are looking for?
> order(c(3,5,2,4,1))
[1] 5 3 1 4 2
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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