You could perhaps do it like that
a<-a[c(1,2,4,3),]
B.
Zhang Yanwei - Princeton-MRAm wrote:
>
> Hi all,
> I have a 4 by 4 matrix, and I want to switch row 2 and row 3 first, then
> switch column 2 and column 3. Is there an easy way to do it?
> The following is a tedious way to get what I wa
Hi Zhang
Hi all, I have a 4 by 4 matrix, and I want to switch row 2 and row 3
first, then switch column 2 and column 3. Is there an easy way to do
it? The following is a tedious way to get what I want. But I wonder
if there is a way to simplify this.
'> a=matrix(rnorm(16),4,4)
'> b=a[c(2,1
sorry here the right thing
a<-a[c(1,3,2,4),c(1,3,2,4)]
B.
Birgitle wrote:
>
> You could perhaps do it like that
>
> a<-a[c(1,2,4,3),]
>
> B.
>
>
> Zhang Yanwei - Princeton-MRAm wrote:
>>
>> Hi all,
>> I have a 4 by 4 matrix, and I want to switch row 2 and row 3 first,
>> then switch co
A <- matrix(rnorm(16)4,4)
o <- c(1,3,2,4)
A[o,o]
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Zhang Yanwei - Princeton-MRAm
Sent: Thursday, August 07, 2008 10:31 AM
To: r-help@r-project.org
Subject: [R] Switch two rows in a matrix
Hi all,
I
Hi all,
I have a 4 by 4 matrix, and I want to switch row 2 and row 3 first, then
switch column 2 and column 3. Is there an easy way to do it?
The following is a tedious way to get what I want. But I wonder if there is a
way to simplify this.
> a=matrix(rnorm(16),4,4)
> a
[,1]
5 matches
Mail list logo