title: R ggplot2 Multiple Lines in Connected Scatterplot
body: <p>I need to plot multiple lines in a connected scatterplot, but am running into issues. I can plot one line, but not the other (or more).</p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>library(dplyr)
  library(ggplot2)
  library(ggrepel)
  library(tidyr)
  
  year&lt;-c(2010,2011,2012,2013,2014,2015,2016,2017,2018,2019)
  
  variableA1&lt;-c(56,169,313,595,797,989,934,869,824,662)
  variableB1&lt;-c(0,0,5,12,23,44,73,71,78,103)
  
  variableA2&lt;-c(22,58,159,342,603,1021,1589,2071,2268,2044)
  variableB2&lt;-c(1,1,0,3,7,9,33,59,84,98)
  
  
  data&lt;-data.frame(year,variableA1,variableB1,variableA2,variableB2)
  
  data %&gt;% 
    ggplot(aes(x=variableA1, y=variableB1, label=year)) +
       geom_point(color="#333333") + 
       geom_text_repel() +
       geom_segment(color="#333333", 
                  aes(
                      xend=c(tail(variableA1, n=-1), NA), 
                      yend=c(tail(variableB1, n=-1), NA)
                  ),
                  arrow=arrow(length=unit(0.3,"cm"))
                  ) +
       geom_point(color="#a8a8a8") + 
       geom_text_repel() +
       geom_segment(color="#a8a8a8", 
                  aes(
                      xend=c(tail(variableA2, n=-1), NA), 
                      yend=c(tail(variableB2, n=-1), NA)
                  ),
                  arrow=arrow(length=unit(0.3,"cm"))
                  )
  </code></pre>
  
  <p><strong>ggplot Chart</strong></p>
  
  <p><img src="https://i.stack.imgur.com/vSUud.png" alt="Connected Scatterplot"></p>