Skip to content
Prev 302669 / 398502 Next

Outer product from matrix by row and a vector

On Aug 7, 2012, at 9:02 PM, Ingo Reinhold wrote:

            
(You really should not be referring to a and b inside that function  
body. It's arguments are now named x and y.)

Can you tell us what the answer _should_ be for the first entry? And a  
step by step illustration of how you got there?

If this is not what it should be, then you need to read up on the  
expected result of the division of a scalar by a vector in R.

  apply(a, 1, function(x) { x[1] + x[3]/ b } )

          [,1] [,2]
[1,] 6.000000  8.0
[2,] 3.500000  5.0
[3,] 2.666667  4.0
[4,] 2.250000  3.5
Do "this" is still somewhat nebulous.
David Winsemius, MD
Alameda, CA, USA