I have this tibble of tibbles:
a = tibble(a = c(1:3))
df <- tibble::tibble(a1 = list(a,a), a2 = list(NULL,a))
# A tibble: 2 x 2
a1 a2
<list> <list>
1 <tibble [3 x 1]> <NULL>
2 <tibble [3 x 1]> <tibble [3 x 1]>
I'd like to replace the <NULL> value with another tibble, let's say a.
But,
df %>% tidyr::replace_na(list(a2 = a))
Gives this
# A tibble: 2 x 2
a1 a2
<list> <list>
1 <tibble [3 x 1]> <int [3]>
2 <tibble [3 x 1]> <tibble [3 x 1]>
While I'd like this
# A tibble: 2 x 2
a1 a2
<list> <list>
1 <tibble [3 x 1]> <tibble [3 x 1]>
2 <tibble [3 x 1]> <tibble [3 x 1]>
Is there an easy workaround?