title: Connecting points from two datasets with lines in ggplot2 in R
body: <p>I want to connect datapoints from two datasets with a vertical line. The points that should be connected vertically have the same identifier (V), but I was hoping to keep the datasets separate.</p>
  
  <p>Here is my figure so far:</p>
  
  <pre><code>d1 &lt;- data.frame (V = c("A", "B", "C", "D", "E",  "F", "G", "H"), 
                    O = c(9,2.5,7,8,7,6,7,7.5), 
                    S = c(6,5,3,5,3,4,5,6))
  
  d2 &lt;- data.frame (V = c("A", "B", "C", "D"), 
                O = c(10,3,7.5,8.2), 
                S = c(6,5,3,5))
  
  scaleFUN &lt;- function(x) sprintf("%.0f", x)
  p&lt;-ggplot(data=d1, aes(x=S, y=O), group=factor(V), shape=V) +
   geom_point(size = 5, aes(fill=V),pch=21, alpha = 0.35)+
   theme_bw()+
  geom_point(data = d2, size=5, aes(fill=V), pch=22,colour="black")+
  theme(legend.title=element_blank())+
  xlab(expression(italic("S"))) + theme(text = element_text(size=25))+
  ylab(expression(italic("O")))+ theme(text = element_text(size=25))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  theme(axis.text.y=element_text(angle=90, hjust=1))+
  theme(legend.position="none") # remove legend
  
  print(p)
  </code></pre>
  
  <p>So the final figure would look something like this: <a href="https://i.stack.imgur.com/jNllI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jNllI.png" alt="Figure"></a>
  Can I do this with geom_line() without combining datasets (so the other formatting can be separate for each dataset)? </p>