title: Keep R code running despite Errors?
body: <p>Using this code function from a previous stackoverflow:<a href="https://stackoverflow.com/questions/22887833/r-how-to-geocode-a-simple-address-using-data-science-toolbox">R: How to GeoCode a simple address using Data Science Toolbox</a></p>
  
  <pre><code>require("RDSTK")
  library(httr)
  library(rjson)
  
  geo.dsk &lt;- function(addr){ # single address geocode with data sciences toolkit
   require(httr)
   require(rjson)
    url      &lt;- "http://www.datasciencetoolkit.org/maps/api/geocode/json"
   response &lt;- GET(url,query=list(sensor="FALSE",address=addr))
  json &lt;- fromJSON(content(response,type="text"))
  loc  &lt;- json['results'][[1]][[1]]$geometry$location
  return(c(address=addr,long=loc$lng, lat= loc$lat))
  }
  </code></pre>
  
  <p>Now Example Code. This works fine:</p>
  
  <pre><code>City&lt;-c("Atlanta, USA", "Baltimore, USA", "Beijing, China")
  r&lt;- do.call(rbind,lapply(as.character(City),geo.dsk))
  </code></pre>
  
  <p>This does not work.It says: "Error in json["results"][[1]][[1]] : subscript out of bounds"</p>
  
  <pre><code> Citzy&lt;-c("Leicester, United Kingdom")
   do.call(rbind,lapply(as.character(Citzy),geo.dsk))
  </code></pre>
  
  <p>I believe the error is because it cannot find the city. So I would like the code to just ignore it and keep running. How would I go about doing this? Any help would be greatly appreciated! </p>