[R] Vector- matrix arithmatic

Laurent Gautier gautier at lion-ag.de
Tue Aug 31 14:40:11 CEST 1999


Peter Ho wrote:

> Hi,
>
> I have a matrix X of nrow=64 and ncol=5 and 2 vectors a and b both of length=5. I
> want to find
> the values for Y = a + (X-b) such that the operation of X is done by rows and not
> by columns.

Try

Y _ a + ( t(X) - b )

It should do it...



Laurent


PS : I wonder what kind of elegant solution the R-masters will give this time : I
particularly appreciated the dim(Z) _ NULL recently mentionned....

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list