title: Creating tables with descriptive statistics in R
body: <p>I would like some help on creating formatted tables in R - whether it's just using the normal IDE or R Markdown. There are two main things that I'd like to do:</p>
  <ul>
  <li>Present the descriptive statistics (Mean, Median, Min, Max) by group based on different columns</li>
  <li>Present the descriptive statistic based on the total sample (ungrouped data)</li>
  </ul>
  <p>Sample data:</p>
  <pre><code>   df &lt;- data.frame(Gender = c(&quot;F&quot;, &quot;M&quot;, &quot;F&quot;, &quot;M&quot;, &quot;M&quot;, &quot;M&quot;, &quot;M&quot;, &quot;F&quot;, &quot;M&quot;, &quot;M&quot;),
                   Young = c(&quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;, &quot;Y&quot;, &quot;N&quot;),
                   Age = c(&quot;14&quot;, &quot;25&quot;, &quot;13&quot;, &quot;24&quot;, &quot;14&quot;, &quot;25&quot;, &quot;13&quot;, &quot;24&quot;, &quot;10&quot;, &quot;26&quot;),
                   Location = c(&quot;Suburb&quot;, &quot;Rural&quot;, &quot;Suburb&quot;, &quot;Rural&quot;,&quot;Suburb&quot;, &quot;Rural&quot;,&quot;Suburb&quot;, &quot;Rural&quot;,&quot;Suburb&quot;, &quot;Rural&quot;))
  </code></pre>
  <p>Expected results</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Variable</th>
  <th>Mean</th>
  <th>Median</th>
  <th>Max</th>
  <th>Min</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td><strong>Gender</strong></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Female</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Male</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td><strong>Location</strong></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Suburb</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td>Rural</td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  <tr>
  <td><strong>TOTAL</strong></td>
  <td></td>
  <td></td>
  <td></td>
  <td></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Is there a way to do this in R?</p>