Skip to content
Prev 155544 / 398502 Next

Substitute Values in a Matrix?

Hi,

I'm searching for a function to subistute Values in a Matrix to new Values.
For example: 

old value  new value
1.1             6
1.2             7
.                .
.                .
.                .
1.9             14
2.0             15

and

2.1             15.5
2.2             16
.                .
.                .
2.9             19.5
3.0             20

There is a difference between the correlation old to new value

For the present my code is like this:

y <- matrix(c(1,2,1, 3,2,4, 1,1,1), ncol=3, byrow=TRUE)

for (i in 1:3) {
 for (j in 1:3) {
   if y[i,j] = 1:2 substitute y[i,j] = 6:15


}
}

But I don't find a correct syntax for this term " if y[i,j] = 1:2 substitute
y[i,j] = 6:15" and I'm not sure if my idea is to simple and it's more
complex than I think.

thanks.