title: R - Applying same function on multiple columns
body: <p>This is my first time asking a question here and I'm a beginner at R.</p>
  
  <p>I have a huge dataset, where I want to get some overview of the values of multiple columns, based on category:</p>
  
  <pre><code>sampleID|category|element_1|element_2|element_3|element_4|
  ----------------------------------------------------------
      1   |    A   |  12.53  |   46.17 |   94.09 |  25.23  |
      2   |    B   |  19.53  |   16.17 |   14.09 |  28.23  |
      3   |    C   |  21.53  |   56.17 |   24.09 |  26.23  |
      4   |    D   |  18.53  |   96.17 |   34.09 |  21.23  |
      5   |    B   |  17.53  |   76.17 |   44.09 |  24.23  |
      6   |    A   |  32.53  |   36.17 |   54.09 |  25.23  |
  </code></pre>
  
  <p>What I've been trying to do is get a mean of each element by each category, what I've been mostly trying are things around <code>tapply</code> function in R:</p>
  
  <pre><code>tapply(data$element1, data$category, mean)
  </code></pre>
  
  <p>This gives me nice results for one element column, but I cannot seem to find an answer how to do that on all columns, without doing it on each column of elements by hand (mean of element1, element2, element3 etc. by category).</p>
  
  <p>What I want is this:</p>
  
  <pre><code>category | element_1| element_2| element_3 
       A   |   mean   |   mean   |   mean
       B   |   mean   |   mean   |   mean
       C   |   mean   |   mean   |   mean
  </code></pre>
  
  <p>I've tried versions of <code>apply</code> and <code>aggregate</code>, but cannot get it to work.</p>
  
  <p>Any advice is appreciated, if I need to supply more information, please let me know!</p>