Rectangling data: applications
Rectangling specific elements of a nested list: use tidyr::hoist()
!
locations |>
select(city, formatted_address, geometry) |>
hoist(
geometry,
ne_lat = c("bounds", "northeast", "lat"),
sw_lat = c("bounds", "southwest", "lat"),
ne_lng = c("bounds", "northeast", "lng"),
sw_lng = c("bounds", "southwest", "lng"),
) |>
select(!geometry)
## # A tibble: 7 × 6
## city formatted_address ne_lat sw_lat ne_lng sw_lng
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Houston Houston, TX, USA 30.1 29.5 -95.0 -95.8
## 2 Washington Washington, USA 49.0 45.5 -117. -125.
## 3 Washington Washington, DC, USA 39.0 38.8 -76.9 -77.1
## 4 New York New York, NY, USA 40.9 40.5 -73.7 -74.3
## 5 Chicago Chicago, IL, USA 42.0 41.6 -87.5 -87.9
## 6 Arlington Arlington, TX, USA 32.8 32.6 -97.0 -97.2
## 7 Arlington Arlington, VA, USA 38.9 38.8 -77.0 -77.2