[R] Help on sorting apologies
Richard Rowe
Richard.Rowe at jcu.edu.au
Thu Sep 19 06:27:59 CEST 2002
At 09:46 19/09/02 +1000, you wrote:
>At 15:14 18/09/02 -0700, you wrote:
>>To: r-help-request at lists.R-project.org
>>
>>From: "Dr. Chris Wills" <cwills at ucsd.edu>
>>
>>Subject: Questions about sorting and functions
>>Cc:
>>
>>Bcc:
>>
>>X-Attachments:
>>Dear Gang -
>> Two questions for you:
>> 1) I cannot figure out how to sort one column in an array, and
>> drag the rest of the values that occupy the other columns along with the
>> sorted values in the first column. What I would like to end up with is
>> an array that is the same size and dimensions as the first array. When
>> I try various configurations of sort, I keep getting vectors instead of
>> the array I started with, and I have not found a way to make sort "bind"
>> other values to the sorted values.
>
>does
>B<-A[,c(order(A[,2]))]
B<-A[,c(order(A[,2]))] ERROR should have been B <- A[c(order(A[,2])),] as
it was in the example (2 can be any column index)
Richard Rowe
Senior Lecturer
Department of Zoology and Tropical Ecology, James Cook University
Townsville, Queensland 4811, Australia
fax (61)7 47 25 1570
phone (61)7 47 81 4851
e-mail: Richard.Rowe at jcu.edu.au
http://www.jcu.edu.au/school/tbiol/zoology/homepage.html
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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