title: R - Error: is.character(location) is not TRUE
body: <p>I am new to R. I found a script online which is used to batch geocode a list of addresses. </p>
  
  <p><a href="http://www.storybench.org/geocode-csv-addresses-r/" rel="nofollow noreferrer">http://www.storybench.org/geocode-csv-addresses-r/</a></p>
  
  <p>However I keep getting this error message 'Error: is.character(location) is not TRUE'...anyone have any ideas on how to reslove the issue??</p>
  
  <pre><code># Geocoding script for large list of addresses. 
  # Finbar Gillen 25/07/2018
  #load up the ggmap library
  install.packages('ggmap')
  library(ggmap)
  # Select the file from the file chooser
  fileToLoad &lt;- file.choose(new = TRUE)
  
  # Read in the CSV data and store it in a variable
  origAddress &lt;- read.csv(fileToLoad, stringsAsFactors = FALSE)
  
  # Initialize the data frame
  geocoded &lt;- data.frame(stringsAsFactors = FALSE)
  
  # Loop through the addresses to get the latitude and longitude 
  of each address and add it to the
  # origAddress data frame in new columns lat and lon
  for(i in 1:nrow(origAddress))
  {
    # Print("Working...")
    result &lt;- geocode(origAddress$addresses[i], output = 
  "latlona", source = "google")
    origAddress$lon[i] &lt;- as.numeric(result[1])
    origAddress$lat[i] &lt;- as.numeric(result[2])
    origAddress$geoAddress[i] &lt;- as.character(result[3])
  }
  # Write a CSV file containing origAddress to the working 
  directory
  write.csv(origAddress, "geocoded.csv", row.names=FALSE)
  </code></pre>