Open
Description
I don't love that when you read code like this:
locations <- gmaps_cities |>
unnest_wider(json) |>
select(-status) |>
unnest_longer(results) |>
unnest_wider(results)
You have no idea what columns you'll end up with, and if the data structure changes, this code will continue to work just giving you new columns names that will cause a potentially confusing downstream failure.
It might be nice if you could specify the column names you expect:
locations <- gmaps_cities |>
unnest_wider(json, new = c("results", "status")) |>
select(-status) |>
unnest_longer(results) |>
unnest_wider(results, new = c("city", "address_components", "formatted_address", "geometry", "place_id", "types"))
OTOH, it seems unlikely that people would actually do this with out some helper that would automatically add to their code and we'd need to carefully think through the semantics of these columns (i.e. it feels like it shouldn't error if there were additional columns not included in the list?)