[R] Sorting a matrix

Jorge Ivan Velez
Thu, 10 Jul 2008 18:32:04 -0000

Dear Angelo,

What about this?

mydata=read.table(textConnection("Name    Sex             Age
Fred    M               24
John    M               18
Mary    F               21"), header=TRUE,sep="")

mydata[order(mydata$Age),]

HTH,

Jorge


On Thu, Jul 10, 2008 at 2:21 PM, Angelo Scozzarella <
angeloscozzarella@tiscali.it> wrote:

> Hi,
>
> I want to sort a matrix by a specific variable without changing the row
> binding between variables.
>
> Ex.
>
> Name    Sex             Age
> Fred    M               24
> John    M               18
> Mary    F               21
>
>
> ordered by Age
>
>
> Name    Sex             Age
> John    M               18
> Mary    F               21
> Fred    M               24
>
>
>
> Thanks
>
>
>
> Angelo
>
> ______________________________________________
> R-help@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.
>

	[[alternative HTML version deleted]]