[R] Element-by-element multiplication operator?

David Forrest drf5n at maplepark.com
Wed Nov 9 20:59:55 CET 2005


On Wed, 9 Nov 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...

It is the default:

matrix(1:6,nrow=2) * cbind(1:2,1:2,1:2)
     [,1] [,2] [,3]
[1,]    1    3    5
[2,]    4    8   12

>
> Thanks
>
> -Mike Gates
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
 Dr. David Forrest
 drf at vims.edu                                    (804)684-7900w
 drf5n at maplepark.com                             (804)642-0662h
                                   http://maplepark.com/~drf5n/




More information about the R-help mailing list