title: ggplot2 line plot order
body: <p>I have a series of ordered points as shown below:
  <img src="https://i.stack.imgur.com/gkvSG.jpg" alt="enter image description here"></p>
  
  <p>However when I try to connect the points by a line, I get the following output:
  <img src="https://i.stack.imgur.com/T4jLP.jpg" alt="enter image description here"></p>
  
  <p>The plot is connecting 26 to 1 and 25 to 9 and 10 (some of the errors), instead of following the order. The code for plotting the points is given below:</p>
  
  <pre><code>p&lt;-ggplot(aes(x = x, y = y), data = spat_loc)
  p&lt;-p + labs(x = "x Coords (Km)", y="Y coords (Km)") +ggtitle("Locations")
  p&lt;-p + geom_point(aes(color="Red",size=2)) + geom_text(aes(label = X))
  p + theme_bw()
  </code></pre>
  
  <p>Plotting code:</p>
  
  <pre><code>p + 
  geom_line((aes(x=x, y=y)),colour="blue") +
  theme_bw()
  </code></pre>
  
  <p>The file which contains the locations have the following structure:</p>
  
  <pre><code>X    x    y
  1    210  200 
  .
  .
  .
  </code></pre>
  
  <p>where X is the numeric ID and x and y are the pair of co-ordinates.</p>
  
  <p>What do I need to do to make the line follow the ordering of points?</p>