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

Feature request: .vary in expand_grid() #1543

Open
lhdjung opened this issue Feb 25, 2024 · 0 comments
Open

Feature request: .vary in expand_grid() #1543

lhdjung opened this issue Feb 25, 2024 · 0 comments

Comments

@lhdjung
Copy link

lhdjung commented Feb 25, 2024

expand_grid() is meant to replace the purrr::cross() family. However, these functions vary fastest, and expand_grid() only varies slowest (in the sense of vec_expand_grid()).

Although varying slowest might be more useful overall, there is no other designated replacement for the cross() functions. Their current docs say that cross() and expand_grid() can be used equivalently, but as that very example shows, the order of combinations is different. This was first noted in tidyverse/purrr#768.

It would be truly equivalent if expand_grid() had a .vary parameter passed to vec_expand_grid() that could be set to "fastest" in this case. The default should still be "slowest". Alternatively, vec_expand_grid() itself could fulfill this role, which should then be advertised in the cross() docs.

Some use cases do require varying fastest (although I don't know how common this is). For example, the vectors creating the background patterns in these plots were made using cross2(), and the patterns wouldn't emerge when varying slowest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant