[R] to modify a matrix

Mitsuo Igarashi mitsu5 at ruby.famille.ne.jp
Sat Feb 8 16:05:06 CET 2003


Hi All.

I am quite a newbie to R.
This is a next basic question.

I have a matrix;
> x <- matrix(1:10.,5)
> x
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8
[4,]    4    9
[5,]    5   10

I like to get a modified matrix as follows;
     [,1] [,2]
[1,]    1    6
[2,]    2    7
[3,]    3    8 * 5 -> 40
[4,]    4    9
[5,]    5   10

The following expression does not work.
 if (x[x[,1]==3])  x[x[,1]==3],2]*5

How can I obtain a right expresion to get a modified matrix?

Thanks in advance for help.

-------========--------
mitsu5
mitsu5 at ruby.famille.ne.jp




More information about the R-help mailing list