Skip to content

Consider moving the dots in pivot_wider() and pivot_longer() #1350

@DavisVaughan

Description

@DavisVaughan

We'd move them up front, like:

pivot_longer(
  data,
  cols,
  ...,
  cols_vary = "fastest",
  names_to = "name",
  names_prefix = NULL,
  names_sep = NULL,
  names_pattern = NULL,
  names_ptypes = NULL,
  names_transform = NULL,
  names_repair = "check_unique",
  values_to = "value",
  values_drop_na = FALSE,
  values_ptypes = NULL,
  values_transform = NULL
)

pivot_wider(
  data,
  ...,
  id_cols = NULL,
  id_expand = FALSE,
  names_from = name,
  names_prefix = "",
  names_sep = "_",
  names_glue = NULL,
  names_sort = FALSE,
  names_vary = "fastest",
  names_expand = FALSE,
  names_repair = "check_unique",
  values_from = value,
  values_fill = NULL,
  values_fn = NULL,
  unused_fn = NULL
)

This has two big benefits:

  • Allows us to add more optional arguments to the generic without fear of breaking packages that have written methods for these generics. As long as the optional arguments come after the ... in the generic, then there won't be a CRAN check warning.

  • Forces users to specify the optional arguments by name. This is nice because we can add new optional arguments in any order without fear of breaking any positional arguments. This is particularly important for package code, where reliance on positional argument ordering can cause a CRAN failure

See #1347 (comment) for more details and some motivation

This would be a breaking change for anyone who is currently relying on positional arguments. But the cols_vary addition is already a breaking change for the same reason, so it seems like a nice time to change this too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change ☠️API change likely to affect existing codefeaturea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions