title: Different outputs with pipe after arithmetic operator vs calling it directly
body: <p>I'm getting an unexpected result when piping a matrix into <code>as.data.frame</code> and could use some wisdom on why it's happening. When I run the below code:</p>
  <pre><code>library(magrittr)
  matrix(c(1,0,0,1), nrow = 2)*5 %&gt;% as.data.frame()
  </code></pre>
  <p>I'm expecting to get</p>
  <pre><code>  V1 V2
  1  5  0
  2  0  5
  </code></pre>
  <p>but instead I get</p>
  <pre><code>  .
  1 5
  </code></pre>
  <p>This is confusing because it works fine when I wrap the <code>as.data.frame</code> call around the matrix construction:</p>
  <pre><code>&gt; as.data.frame(matrix(c(1,0,0,1), nrow = 2)*5)
    V1 V2
  1  5  0
  2  0  5
  </code></pre>
  <p>and when I pipe the multiplication function as well:</p>
  <pre><code>&gt; matrix(c(1,0,0,1), nrow = 2) %&gt;% `*`(5) %&gt;% as.data.frame()
    V1 V2
  1  5  0
  2  0  5
  </code></pre>
  <p>and when I save the intermediate result and pipe that into the next function:</p>
  <pre><code>&gt; v &lt;- matrix(c(1,0,0,1), nrow = 2)*5
  &gt; v %&gt;% as.data.frame()
    V1 V2
  1  5  0
  2  0  5
  </code></pre>
  <p>This made me pretty sure it's due to the arithmetic operation being performed before sending it into the pipe, which we can confirm with other arithmetic and other functions to ensure it's not particular to the <code>*</code> operator or the <code>as.data.frame</code> function:</p>
  <pre><code># Plus instead of times
  &gt; matrix(c(1,0,0,1), nrow = 2)+1 %&gt;% as.data.frame()
    .
  1 2
  
  # rowSums instead of as.data.frame()
  &gt; matrix(c(1,0,0,1), nrow = 2)*5 %&gt;% rowSums()
  Error in rowSums(.) : 'x' must be an array of at least two dimensions
  </code></pre>
  <p>I'm clearly not understanding how pipes work with arithmetic operators or what the arithmetic functions return(?) so I could use some advice for what's happening here. Is this a known quirk of which I haven't been able to find documentation? Hadley's book doesn't mention this being an issue in the <a href="https://r4ds.had.co.nz/pipes.html" rel="nofollow noreferrer">chapter on pipes</a> and the Technical Notes section of <code>help(&quot;%&gt;%&quot;)</code> seems to only caution against functions that capture their calling environment. The final note there mentions arithmetic operators but makes it seem like it's only operator precedence that's affected when the results are different from switching the <code>as.data.frame</code> call and the multiplication step:</p>
  <pre><code>matrix(c(1,0,0,1), nrow = 2) %&gt;% as.data.frame() %&gt;% `*`(5)
    V1 V2
  1  5  0
  2  0  5
  </code></pre>
  <p><strong>Why do I get different results when piping a arithmetically-modified matrix into another function?</strong></p>