title: Scalar Multiplication in R
body: <p>I'm trying to perform simple scalar multiplication in R, but I'm running into a bit of an issue.</p>
  
  <p>In linear algebra I would do the following:</p>
  
  <p><img src="https://i.stack.imgur.com/hdmt1.png" alt="scalar multiplication"></p>
  
  <p>Here's how I've implemented this in R:</p>
  
  <pre><code>A &lt;- matrix(1:4, 2, byrow = TRUE)
  c &lt;- matrix(rep(3, 4), 2)
  A * c
  </code></pre>
  
  <p>This produces the correct output, but creating the scalar matrix <em>c</em> will be cumbersome when it comes to larger matrices.</p>
  
  <p>Is there a better way to do this?</p>