title: Create a square grid in a dataframe in R
body: <p>I'm trying to create a 5 x 5 grid which will be overlayed on a map, I have starting latitude and longitude coordinates, which could be the top right hand corner of the grid for example (doesn't really matter). each point would be an equal (say -10) amount different to the previous coordinates.</p>
  
  <p>I'm having trouble coding it:</p>
  
  <pre><code>latcoords  &lt;- c(origincoords$results$geometry$location$lat)
  lngcoords  &lt;- c(origincoords$results$geometry$location$lng)
  
  griddf &lt;- data.frame(latcoords, lngcoords)
  names(griddf)[1]&lt;-paste("latcoords")
  names(griddf)[2]&lt;-paste("lngcoords")
  x &lt;- 1 
  y &lt;- 1
  while(x &lt; 5){
  while(5  &lt; 5) {
      griddf &lt;- rbind(griddf$latcoords[x] -10, griddf$lngcoords[x])
  
      }
  griddf &lt;- rbind(griddf$latcoords[x], griddf$lngcoords[x] - 10)
  x &lt;- x + 1
  y &lt;- 1
  }
  </code></pre>
  
  <p>Where am I going wrong here...</p>