jim holtman wrote:
> Lets take a look at your solution:
>
>> mat1 <- matrix(0, nrow=10, ncol=3)
>> dimnames(mat1) <- list(paste('row', 1:10, sep=''), LETTERS[1:3])
>> mat2 <- matrix(1:3, ncol=1, dimnames=list(c('row3', 'row7', 'row5'), "B"))
>> mat2
> B
> row3 1
> row7 2
> row5 3
>> mat1[rown
Lets take a look at your solution:
> mat1 <- matrix(0, nrow=10, ncol=3)
> dimnames(mat1) <- list(paste('row', 1:10, sep=''), LETTERS[1:3])
> mat2 <- matrix(1:3, ncol=1, dimnames=list(c('row3', 'row7', 'row5'), "B"))
> mat2
B
row3 1
row7 2
row5 3
> mat1[rownames(mat2)%in%rownames(mat1),"B"]=ma
jim holtman wrote:
> Here is one way of doing it that uses the row and column names:
>
>> # create test data
>> mat1 <- matrix(0, nrow=10, ncol=3)
>> dimnames(mat1) <- list(paste('row', 1:10, sep=''), LETTERS[1:3])
>> mat2 <- matrix(1:3, ncol=1, dimnames=list(c('row3', 'row7', 'row5'), "B"))
>> ma
Here is one way of doing it that uses the row and column names:
> # create test data
> mat1 <- matrix(0, nrow=10, ncol=3)
> dimnames(mat1) <- list(paste('row', 1:10, sep=''), LETTERS[1:3])
> mat2 <- matrix(1:3, ncol=1, dimnames=list(c('row3', 'row7', 'row5'), "B"))
> mat2
B
row3 1
row7 2
row5
I guess this has a simple solution:
I have matrix 'mat1' which has row and column names, e.g.:
A B C
row10 0 0
row20 0 0
rown0 0 0
I have a another matrix 'mat2', essentially a subset of 'mat1' where the
rownames are all i
5 matches
Mail list logo