You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
393B

  1. list_transpose_bind <- function(x) {
  2. if (is.null(x) || length(x) == 0) return(x)
  3. purrr::reduce(x, list_transpose_bind_impl)
  4. }
  5. list_transpose_bind_impl <- function(x, acc) {
  6. if (!length(x)) return(acc)
  7. for (name in names(x)) {
  8. if (!name %in% names(x)) {
  9. acc[[name]] <- x[[name]]
  10. } else {
  11. acc[[name]] <- dplyr::bind_rows(acc[[name]], x[[name]])
  12. }
  13. }
  14. acc
  15. }