title: R Dumbbell chart with legend, unable to sort y-axis
body: <p>I'm trying to build a dumbbell chart in R that includes a legend and the ability to sort by a value other than the y-axis.</p>
  
  <p>I can get these requirements individually in 2 separate plots but unable to use both features in one chart.  </p>
  
  <p>Here's the script showing the plot with legend and no custom sorting:</p>
  
  <pre><code>library(ggalt)
  df &lt;- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))
  df2 = tidyr::gather(df, group, value, -trt)
  ggplot(df, aes(y = trt))+ 
    geom_point(data = df2, aes(x = value, color = group), size = 3) +
    geom_dumbbell(aes(x = l, xend = r), size=3, color="#e3e2e1", 
                  colour_x = "red", colour_xend = "blue",
                  dot_guide=TRUE, dot_guide_size=0.25) +
    theme_bw() +
    scale_color_manual(name = "", values = c("red", "blue") )
  </code></pre>
  
  <p>Here's the script showing the plot with no legend and custom sorting:</p>
  
  <pre><code>library(ggalt)
  df &lt;- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))
  ggplot(df, aes(y=reorder(trt,-l), x=l, xend=r)) + 
    geom_dumbbell(aes(x = l, xend = r), size=3, color="#e3e2e1", 
                  colour_x = "red", colour_xend = "blue",
                  dot_guide=TRUE, dot_guide_size=0.25) +
    theme_bw() +
    scale_color_manual(name = "", values = c("red", "blue") )
  </code></pre>
  
  <p>When i try to add the two together I receive an error "Error in tapply(X = X, INDEX = x, FUN = FUN, ...) : 
    arguments must have same length"  below is the script i'm using:</p>
  
  <pre><code>library(ggalt)
  df &lt;- data.frame(trt=LETTERS[1:5], l=c(20, 40, 10, 30, 50), r=c(70, 50, 30, 60, 80))
  df2 = tidyr::gather(df, group, value, -trt)
  ggplot(df, aes(y=reorder(trt,-l), x=l, xend=r)) + 
    geom_point(data = df2, aes(x = value, color = group), size = 3) +
    geom_dumbbell(aes(x = l, xend = r), size=3, color="#e3e2e1", 
                  colour_x = "red", colour_xend = "blue",
                  dot_guide=TRUE, dot_guide_size=0.25) +
    theme_bw() +
    scale_color_manual(name = "", values = c("red", "blue") )
  </code></pre>
  
  <p>Any ideas how to correct this?
  Thanks</p>