title: Producing a boxplot in ggplot2 using summary statistics
body: <p>Below is a code for producing a boxplot using ggplot2 I'm trying to modify in order to suit my problem:</p>
  
  <pre><code>library(ggplot2)
  set.seed(1)
  # create fictitious data
  a &lt;- rnorm(10)
  b &lt;- rnorm(12)
  c &lt;- rnorm(7)
  d &lt;- rnorm(15)
  
  # data groups
  group &lt;- factor(rep(1:4, c(10, 12, 7, 15)))
  
  # dataframe
  mydata &lt;- data.frame(c(a,b,c,d), group)
  names(mydata) &lt;- c("value", "group")
  
  # function for computing mean, DS, max and min values
  min.mean.sd.max &lt;- function(x) {
    r &lt;- c(min(x), mean(x) - sd(x), mean(x), mean(x) + sd(x), max(x))
    names(r) &lt;- c("ymin", "lower", "middle", "upper", "ymax")
    r
  }
  
  # ggplot code
  p1 &lt;- ggplot(aes(y = value, x = factor(group)), data = mydata)
  p1 &lt;- p1 + stat_summary(fun.data = min.mean.sd.max, geom = "boxplot") + ggtitle("Boxplot con media, 95%CI, valore min. e max.") + xlab("Gruppi") + ylab("Valori")
  </code></pre>
  
  <p>In my case I do not have the actual data points but rather only their mean and standard deviation (the data are normally distributed). So for this example it will be:</p>
  
  <pre><code>mydata.mine = data.frame(mean = c(mean(a),mean(b),mean(c),mean(d)),sd = c(sd(a),sd(b),sd(c),sd(d)),group = c(1,2,3,4))
  </code></pre>
  
  <p>However I would still like to produce a boxplot. I thought of defining:
  ymin = mean - 3*sd
  lower = mean - sd
  mean = mean
  upper = mean + sd<br>
  ymax = mean + 3*sd</p>
  
  <p>but I don't know how to define a function that will access mean and sd of mydata.mine from fun.data in stat_summary. Alternatively, I can just use <code>rnorm</code> to draw points from a normal parameterized by the mean and sd I have, but the first option seems to me a bit more elegant and simple. </p>