Re: [R] A factor times a matrix

2013-09-17 Thread arun
3 11:38 PM Subject: Re: [R] A factor times a matrix Hello, To complete Arun's response, you also have: > sweep(b,2,a,'*')      [,1] [,2] [1,]    1    8 [2,]    2   10 [3,]    3   12 or > b %*% diag(a)      [,1] [,2] [1,]    1    8 [2,]    2   10 [3,]    3   12 Regar

Re: [R] A factor times a matrix

2013-09-17 Thread Edouard Hardy
To you have an explanation to this operation ? I don't understand why it is working ! Thank you ! Edouard Hardy On Tue, Sep 17, 2013 at 8:47 AM, Edouard Hardy wrote: > Thank you so much. This is perfect. > > > Edouard Hardy > > > On Tue, Sep 17, 2013 at 5:38 AM, Pascal Oettli wrote: > >> Hell

Re: [R] A factor times a matrix

2013-09-17 Thread Edouard Hardy
Thank you so much. This is perfect. Edouard Hardy On Tue, Sep 17, 2013 at 5:38 AM, Pascal Oettli wrote: > Hello, > > To complete Arun's response, you also have: > > > sweep(b,2,a,'*') > [,1] [,2] > [1,]18 > [2,]2 10 > [3,]3 12 > > or > > > b %*% diag(a) > [,1] [

Re: [R] A factor times a matrix

2013-09-16 Thread Pascal Oettli
Hello, To complete Arun's response, you also have: > sweep(b,2,a,'*') [,1] [,2] [1,]18 [2,]2 10 [3,]3 12 or > b %*% diag(a) [,1] [,2] [1,]18 [2,]2 10 [3,]3 12 Regards, Pascal 2013/9/17 arun > Hi, > t(a*t(b)) > # [,1] [,2] > #[1,]1

Re: [R] A factor times a matrix

2013-09-16 Thread arun
Hi,  t(a*t(b)) # [,1] [,2] #[1,]    1    8 #[2,]    2   10 #[3,]    3   12 A.K. Hello eveybody, I have a vector a and a matrix b : > a [1] 1 2 > b [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 With simple multiplication I get : > a * b [,1] [,2] [1,] 1 8 [2,] 4 5 [3,] 3 12 I would l