Rectangling data by unnesting list columns

df_named <- tribble(
  ~x, ~y,
  1, list(a = 11, b = 12),
  2, list(a = 21, b = 22),
  3, list(a = 31, b = 32),
)
df_named
## # A tibble: 3 × 2
##       x y               
##   <dbl> <list>          
## 1     1 <named list [2]>
## 2     2 <named list [2]>
## 3     3 <named list [2]>

Unnesting a named list column?

  • Usually you want to make it wider.
  • The names become the column names.