Learn R Programming

tidyr (version 1.3.1)

unnest_auto: Automatically call unnest_wider() or unnest_longer()

Description

unnest_auto() picks between unnest_wider() or unnest_longer() by inspecting the inner names of the list-col:

  • If all elements are unnamed, it uses unnest_longer(indices_include = FALSE).

  • If all elements are named, and there's at least one name in common across all components, it uses unnest_wider().

  • Otherwise, it falls back to unnest_longer(indices_include = TRUE).

It's handy for very rapid interactive exploration but I don't recommend using it in scripts, because it will succeed even if the underlying data radically changes.

Usage

unnest_auto(data, col)

Arguments

data

A data frame.

col

<tidy-select> List-column to unnest.