koncina · GitHub

When row-binding a named list containing multiple consecutive NULL elements the resulting data frame identifiers (using the .id argument) are shifted:

library(tidyverse)
list(a = tibble(expected_id = "a"),
     b = NULL,
     c = NULL,
     d = tibble(expected_id = "d"),
     c = NULL,
     e = tibble(expected_id = "e")) %>%
  bind_rows(.id = "id")
#> # A tibble: 3 x 2
#>   id    expected_id
#>   <chr> <chr>      
#> 1 a     a          
#> 2 c     d          
#> 3 d     e

Created on 2019-03-20 by the reprex package (v0.2.1)

Single NULL elements are handled accurately:

library(tidyverse)
list(a = tibble(expected_id = "a"),
     b = NULL,
     c = tibble(expected_id = "c"),
     d = NULL,
     e = tibble(expected_id = "e")) %>%
  bind_rows(.id = "id")
#> # A tibble: 3 x 2
#>   id    expected_id
#>   <chr> <chr>      
#> 1 a     a          
#> 2 c     c          
#> 3 e     e

Created on 2019-03-20 by the reprex package (v0.2.1)

Read the original on github.com ↗