Subject: Re: [R] replacing columns with same names
From: bhh at xs4all.nl
Date: Fri, 14 Nov 2014 16:24:03 +0100
CC: r-help at r-project.org
To: eliza_botto at hotmail.com
On 14-11-2014, at 16:04, eliza botto <eliza_botto at hotmail.com> wrote:
Dear useRs,
I have two matrices
structure(1:15, .Dim = c(3L, 5L), .Dimnames = list(NULL, c("A", "B", "C", "D", "E")))
structure(31:36, .Dim = c(3L, 2L), .Dimnames = list(NULL, c("D", "E")))
I have two question
1-Generally speaking, How can I replace the columns of matrix with the other columns having same names?
2-Precisely, how can I replace column "D" and "E" of "EB" with "D" and "E" of "EA"?
Thankyou very very much in advance.
How about
colnms <- c("D","E")
EB[,colnms] <- EA[,colnms]
Berend