title: How to correctly add average, standard deviation and jitter in geom_plot()? ggplot2
body: <p>I am trying to create a graph that shows the mean, standard deviation and the dots of each value (jitter). However, I was unable to insert the average point and the standard deviations are the same for all categories (and this is incorrect).</p>
  <p><strong>My code (example):</strong></p>
  <pre><code># Package
  library(ggplot2)
  
  # Dataframe
  fruit &lt;- c()
  value &lt;- c()
  for (i in 0:30) {
    list_fruit &lt;- c('Apple','Banana','Pear')
    fruit &lt;- append(fruit, sample(list_fruit, 1))
    value &lt;-  append(value, sample(1:50, 1))
  }
  df &lt;- data.frame(fruit, value)
  
  # Seed
  set.seed(123)
  
  # Plot
  ggplot(df, aes(x = fruit, y = value, color = fruit)) +
    geom_point() +
    geom_jitter(width = 0.1) + 
    geom_linerange(aes(ymin = mean(value)-sd(value), ymax = mean(value)+sd(value)), col = 'black') +
    scale_color_manual(values=c('red','blue','purple'))
  </code></pre>
  <p><strong>Result</strong>
  <a href="https://i.stack.imgur.com/KA57B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KA57B.png" alt="enter image description here" /></a></p>