Albert
Is this what you want?:
a[,order(colSums(a))]
John S
---
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Albert Vilella
Sent: 21 June 2006 11:38
To: r help
Subject: [R] sort matrix by sum of columns
Hi all,
I would like to know how can
Hi
order is your friend
On 21 Jun 2006 at 11:38, Albert Vilella wrote:
From: Albert Vilella <[EMAIL PROTECTED]>
To: r help
Date sent: Wed, 21 Jun 2006 11:38:17 +0100
Subject: [R] sort matrix by sum of columns
Send re
2006 12:38 PM
Subject: [R] sort matrix by sum of columns
> Hi all,
>
> I would like to know how can I sort the cols of a matrix by the sum
> of
> their elements.
>
>
> a <- matrix(as.integer(rnorm(25,4,2)),10,5)
> colnames(a) = c("alfa","bravo",&
Hi all,
I would like to know how can I sort the cols of a matrix by the sum of
their elements.
a <- matrix(as.integer(rnorm(25,4,2)),10,5)
colnames(a) = c("alfa","bravo","charlie","delta","echo")
I guess I should use colSums, and then rearrange the matrix somehow
according to the result.
My id