title: How to make error bars for multiple variables in bar chat
body: <p>I was hoping someone could help me with the following problem: </p>
  
  <p>I am attempting to make a combined barplot showing the mean and standard errors for 3 different continuous variables (body temp, length, mass) recorded for a binary variable (gender). </p>
  
  <p>I have been able to plot the mean values for each variable but I can't seem to successfully calculate the standard error for these 3 variables using any of the codes I've tried. 
  I tried many things, but I think I was on the right track with this: </p>
  
  <pre><code>    View(test4)
      test4 &lt;- aggregate(test4, 
               by = list(Sex = test4$Sex), 
               FUN = function(x) c(mean = mean(x), sd = sd(x),
                                   n = length(x)))
      test4
      #this produced mean, sd, length for ALL variables (including sex)
      test4&lt;-do.call(test4)
      test4$se&lt;-test4$x.sd / sqrt(test4$x.n)
  </code></pre>
  
  <p>Then I kept getting the error: </p>
  
  <pre><code>    Error in sqrt(test4$x.n) : non-numeric argument to mathematical function
  </code></pre>
  
  <p>I tried to recode to target my 3 variables after aggregate(test4...) but I couldn't get it to work...Then I subsetted by resulting dataframe to exclude sex but that didn't work. I then tried to define it as a matrix or vector but still that didn't work. </p>
  
  <p>I would like my final graph to to have y axis = mean values, x axis = variable (3 sub-groups (Tb, Mass, Length) with two bars side by side showing male and female values for comparison. </p>
  
  <p>Any help or direction anyone could provide would be greatly appreciated!!</p>
  
  <p>Many thanks in advance! :) </p>