inbo / iassetR

Interact with the iAsset api using R
https://inbo.github.io/iassetR/
Other
0 stars 1 forks source link

get_records(): handle list columns #1

Closed PietrH closed 8 months ago

PietrH commented 9 months ago

Currently we have a few multivalue in the API output, we still need to handle these more elegantly before we can output to a tibble.

Currently we have exploredtibble::enframe(), and tidyr::pivot_wider()

res %>% httr::content() %>% 
  purrr::pluck("returndata") %>% 
  head(5) %>% 
  purrr::map(~purrr::pluck(.x, "data")) %>%
  # purrr::map(~purrr::map_dfc(.x, function(element){element}))
  purrr::map(~tibble::enframe(.x)) %>% 
  purrr::map_dfr(~ tidyr::pivot_wider(.x, names_from = name))

But I personally think it should probably be handled with a combination of purrr::map_dfc and purrr::map_dfr