Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DavisVaughan opened this issue Apr 12, 2022 · 0 comments · Fixed by #1353
Closed

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

DavisVaughan opened this issue Apr 12, 2022 · 0 comments · Fixed by #1353
Labels
breaking change ☠️ API change likely to affect existing code feature a feature request or enhancement

Comments

@DavisVaughan
Copy link
Member

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.

@DavisVaughan DavisVaughan added feature a feature request or enhancement breaking change ☠️ API change likely to affect existing code labels Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ☠️ API change likely to affect existing code feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant