Skip to content

Investigate whether unpack() should auto skip non-df-cols #1153

Closed
@DavisVaughan

Description

@DavisVaughan

See #1141 (comment)

  • unnest() is forgiving when you try and unnest a column that isn't a "list column of tibbles"
  • unchop() is forgiving when you try and unchop a column that isn't a "list column"
  • unpack() should probably be forgiving when you try and unpack a column that isn't a "df column"

This nice theoretical rationale for this is to make it so that unnest() is literally just unchop() + unpack():

unnest.data.frame <- function(
                              data,
                              cols,
                              ...,
                              keep_empty = FALSE,
                              ptype = NULL,
                              names_sep = NULL,
                              names_repair = "check_unique",
                              .drop = "DEPRECATED",
                              .id = "DEPRECATED",
                              .sep = "DEPRECATED",
                              .preserve = "DEPRECATED") {
  cols <- tidyselect::eval_select(enquo(cols), data)
  data <- unchop(data, any_of(cols), keep_empty = keep_empty, ptype = ptype)
  # REMOVE ME? cols <- cols[map_lgl(unclass(data)[cols], is.data.frame)]
  unpack(data, any_of(cols), names_sep = names_sep, names_repair = names_repair)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementnesting 🐦nesting, chopping, and packing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions