[R] Element-by-element multiplication operator?
Tobias Verbeke
tobias.verbeke at telenet.be
Wed Nov 9 21:07:39 CET 2005
Gates, Michael BGI SF wrote:
>Is there an element-by-element multiplication in R, like the .* operator in Matlab?
>
>eg: A (2x3)
> B (2x3)
>C=A.*B
>C (2x3)
>C = [[a11*b11 a12*b12 a13*b13]; [a21*b21 a22*b22 a23*b23]]
>
>I can't find one...
>
>
mym <- matrix(1:4,2)
myt <- matrix(5:8,2)
> mym
[,1] [,2]
[1,] 1 3
[2,] 2 4
> myt
[,1] [,2]
[1,] 5 7
[2,] 6 8
> mym * myt
[,1] [,2]
[1,] 5 21
[2,] 12 32
HTH,
Tobias
More information about the R-help
mailing list