Re: [R] Multiply row of a matrix

2017-02-21 Thread Jeff Newmiller
Why this works does not become clear until you actually pay attention to how matrices are laid out in memory as a vector, and how vector replication works. Those ideas are not that difficult to learn, but they feel different than in other languages (e.g. matlab) and they make a huge difference

Re: [R] Multiply row of a matrix

2017-02-21 Thread William Dunlap via R-help
> Mat * c(3, 1, 0.5) [,1] [,2] [,3] [1,] 3.06 9.0 [2,] 4.05 6.0 [3,] 3.54 4.5 Bill Dunlap TIBCO Software wdunlap tibco.com On Tue, Feb 21, 2017 at 8:23 AM, wrote: > If we have the following matrix: > > Mat<-matrix(1:9, byrow=TRUE, nrow=3) > Mat > > [,1] [,2] [,3] >

[R] Multiply row of a matrix

2017-02-21 Thread ac . dasilva
If we have the following matrix: Mat<-matrix(1:9, byrow=TRUE, nrow=3) Mat [,1] [,2] [,3] [1,]123 [2,]456 [3,]789 I would like to have each row multiplied by a different number. So I would like row 1 multiplied by 3, row2 by 1 and row3 by 0.5 Which woul