title: Finding dot product in r
body: <p>I am trying to find the dot product of two matrices in R. In the q matrix, which must be transposed, I have three different q values that I randomly generated earlier, and in the z matrix three randomly generated z values that serve as coordinates of a random point i.  I have:</p>
  
  <pre><code>    z0= NULL
      for (i in 1:100){
          z0[i]= 1
      }
      z1= runif(100, min=0, max= 20)
      z2= runif(100, min=0, max=20)
      q0= runif(1, 0, 1)
      q1= runif(1, 0, 1)
      q2= runif(1, 0, 1)
      i= runif(1, 1, 101)
      i= ceiling(i-1)
      q= matrix(c(q0,q1,q2), ncol=3)
      z= matrix(c(z0[i],z1[i],z2[i]), ncol=3)
      s[i]= t(q)*z
  </code></pre>
  
  <p>However, when I try to calculate s[i], I get <code>Error in t(q) * z : non-conformable arrays</code>. I am not sure why this would be as I they seem to both have the same length.</p>
  
  <p>This is my first time using R so I am not really sure what is going on.</p>
  
  <p>Thanks!</p>