Here's one way.
new.matrix <- my.matrix
new.matrix[] <- with(my.df, my.value[match(my.matrix, my.id)])
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Milton Cezar Ribeiro
Sent: Saturday, 24 November 2007 7:14 AM
To: R-help
Subject: [R] upda
Try this (not a lot of error checking -- assumes values 1-5 are in the
matrix and in my.id):
new.matrix <- my.df$my.value[match(my.matrix, my.df$my.id)]
dim(new.matrix) <- dim(my.matrix)
On Nov 23, 2007 4:13 PM, Milton Cezar Ribeiro <[EMAIL PROTECTED]> wrote:
> Dear all,
>
> I have a matrix which
Dear all,
I have a matrix which values varying from 1 to 5.
I also have a table with a column that match with matrix values (=my.id).
my.matrix<-matrix(sample(1:5,100,replace=T),nc=10)
image(my.matrix)
my.df<-data.frame(cbind(my.id=1:5,my.value=c(0.1,0.3,0.2,0.9,1)))
my.df
How can I create a ne
3 matches
Mail list logo