title: How do you calculate row and column totals on a tibble using tidyverse functions
body: <p>Given an n by m tibble with numeric values. How do you calculate row and column totals for the tibble.</p>
  <p>Here is a reprex with a sample tibble:</p>
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  df &lt;- tibble(names=c('a','b','c','d','e'),x = 1:5, y =5:1, z=2:6)
  df
  #&gt; # A tibble: 5 x 4
  #&gt;   names     x     y     z
  #&gt;   &lt;chr&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;
  #&gt; 1 a         1     5     2
  #&gt; 2 b         2     4     3
  #&gt; 3 c         3     3     4
  #&gt; 4 d         4     2     5
  #&gt; 5 e         5     1     6
  </code></pre>
  <p><sup>Created on 2020-06-09 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.3.0)</sup></p>
  <p>Given this tibble I would like efficiently use tidyverse functions to achieve the following output:</p>
  <p><a href="https://i.stack.imgur.com/U9XrL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U9XrL.jpg" alt="enter image description here" /></a></p>
  <p>I have been able to accomplish this with a combination of gathers and spreads and joins, but I'm still fairly new to R and the tidyverse and wanted to see if there was a more efficient way to accomplish this.</p>