title: Functions in R: How to Return Mean, Median, Standard Deviation Within Same Function
body: <p>How can I return the mean, median, and standard deviation within same function in R? All that I can get to return is the last part of the function which calculated the standard deviation. I was thinking that by assigning summarystat(Tail_wags) to b that when I returned 'b' that I would have all three value. Added the result for the three values I need outside of the function after 'b' to see what values are supposed to be.</p>
  
  <pre><code>Dog_biscuits &lt;- c(0,1,2,3,4,5,6,7,8,9,10) 
  Tail_wags &lt;- c(0,0,1,3,8,13,14,12,15,16,14)
  dog_wags&lt;-cbind(Dog_biscuits,Tail_wags)
  dog_wags
  
  summarystat&lt;- function(x) {
    z1 &lt;- mean(x)
    z2&lt;-median(x)
    z3&lt;-sd(x)
  }
  b&lt;-summarystat(Tail_wags)
  b
  
  b
  [1] 6.497552
  &gt; mean(Tail_wags)
  [1] 8.727273
  &gt; median(Tail_wags)
  [1] 12
  &gt; sd(Tail_wags)
  [1] 6.497552
  </code></pre>