ropensci / opencage

:globe_with_meridians: R package for the OpenCage API -- both forward and reverse geocoding :globe_with_meridians:
https://docs.ropensci.org/opencage
87 stars 11 forks source link

Set stringsAsFactor false in opencage_format #43

Closed dpprdan closed 6 years ago

dpprdan commented 6 years ago

See https://github.com/ropensci/opencage/commit/ddac5dc7d31a6a0a563d80fa603cb4a2edf048c6#r27554681

jessesadler commented 6 years ago

Just pulled these changes and found a couple of issues. Using stringsAsFactor = FALSE in the apply chain turns all variables into characters, including lat and lng, which is not what we want. This is because unlist turns the variables into a character vector. Thus, stringsAsFactor = FALSE avoids the factor problem but numbers are turned into characters.

The other issue is that the change to use flatten = TRUE in oc_parse as discussed in issue #40 and proposed in PR #42 changes the structure of the list returned by oc_parse, which breaks the lapply chain.

My proposal is to use flatten = TRUE in PR #42, remove the lapply chain to create a data frame of results, and simply use the data frame of results created by flatten = TRUE within the list output used by opencage_format. This change should not be any more breaking than the current change to stringsAsFactor = FALSE and would return a data frame that handles characters and numbers in a manner consistent with the API and the results from oc_forward and oc_reverse.

dpprdan commented 6 years ago

I think this is fixed now.

maelle commented 6 years ago

Thanks! 🎊