0

Error in encode_locations(origins) : object 'encoded' not found

this error msg was generated when I try to use MapsApi package in Rstudio to calculate the driving time, below is what I tried to put in... ...

locations <- experiment_api_Sheet1
doc = mp_matrix(origins = locations, destinations = "10019", mode = "driving",
                departure_time = Sys.time() + as.difftime(1, units = "mins"),
                key = readLines("~/key"))
r2evans
  • 141,215
  • 6
  • 77
  • 149
Sherry
  • 3
  • 2
  • I think this is a [new bug](https://github.com/michaeldorman/mapsapi/issues/new) in the `mapsapi` package. The [`encode_locations`](https://github.com/cran/mapsapi/blob/f4bb95e0859409d574f25756a8e4e19ff71686b7/R/encode_locations.R) function is poorly written such that `encoded` is only defined if the input is one of four classes; instead of producing an error if that assumption is not met, it tries to return an object that was never created. Regardless, I'll guess that your `locations` is not one of the intended formats. (I may be wrong. Since we know nothing of your data, it's a guess.) – r2evans Nov 23 '21 at 14:29
  • I was just trying anyway, basically, I faked a .csv with a bunch of postcodes in there and tried to test out if this package can give me a summarization of travel durations from different postcode locations (since google map is ok with me to just typeing in the postcodes to ask derections) – Sherry Nov 23 '21 at 14:34
  • do you think assigning area names to postcodes will resolve the problems? – Sherry Nov 23 '21 at 14:35
  • I don't know what your data looks like or what you expect to get in return. Further, I'm not familiar with the `mapsapi` package, so I don't know for certain if what you're trying to do is supported. I suggest you make this question reproducible by adding sample data; see https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Nov 23 '21 at 15:15

0 Answers0