title: Summary stats by factor level for multiple variables
body: <p>I want to produce dataframes containing summary statistics for each factor level for multiple variables.</p>
  
  <p>For example if I have the following dataframe</p>
  
  <pre><code>Factor &lt;- c("A","A","A","B","B","B")
  Variable1 &lt;- c(3,4,5,4,5,3)
  Variable2 &lt;- c(7,9,14,16,10,10)
  mydf &lt;- data.frame(Factor, Variable1, Variable2)
  mydf
    Factor Variable1 Variable2
  1      A         3         7
  2      A         4         9
  3      A         5        14
  4      B         4        16
  5      B         5        10
  6      B         3        10
  </code></pre>
  
  <p>and I have the following function that I want to use to produce my summary stats:</p>
  
  <pre><code>my.summary &lt;- function(x, na.rm=TRUE){result &lt;- c(n=as.integer(length(x)),
  Mean=mean(x, na.rm=TRUE), SD=sd(x, na.rm=TRUE), SeM = SEM(x),
  Median=median(x),   Min=min(x), Max=max(x))}
  </code></pre>
  
  <p>To apply this to factor levels of Variable1 I can do this:</p>
  
  <pre><code>ddply(mydf, c("Factor"), function(x) my.summary(x$Variable1))
    Factor n Mean SD       SeM Median Min Max
  1      A 3    4  1 0.5773503      4   3   5
  2      B 3    4  1 0.5773503      4   3   5
  </code></pre>
  
  <p>Now I can do the same for Variable 2:</p>
  
  <pre><code>ddply(mydf, c("Factor"), function(x) my.summary(x$Variable2))
  </code></pre>
  
  <p>Which is easy enough if I just have 2 variables. However, if I had lots of variables this would be a pain. So how can I solve this so that I can produce a dataframe of the summary stats for each variable/factor level without having to adjust the code?</p>
  
  <p>I have tried using aggregate.data.frame but it doesn't work using my.summary. It works using summary but produces one big data frame.</p>
  
  <p>Thanks</p>