Implement pivot_wider and pivot_longer #98
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@nathaneastwood it was faster than I thought to implement this. I basically copied the code from
datawizard
functions, changed the select helpers and removed otherdatawizard
functions. Not all arguments are implemented but I think it's a good start. Below are some examples to check thatpoorman
andtidyr
outputs match (these are also implemented in tests).Things to note:
tidyr::pivot_wider
is about the NSE. For example, the following works withtidyr
but not withpoorman
:To make it work with
poorman
, we need to use quoted names. Maybe I simply missed something about how you deal with NSE in your package.I added
tidyr
in Suggests and loaded it in the tests for pivot_ functions but it has some side effects on other tests because of namespace collisions. I think it is useful to test that the outputs of tidyr and poorman match so I'd like to keep these but I don't know how to deal with these side effects (never used tinytest before). What do you think?I'm not very familiar with your coding style so let me know if I should improve the syntax in some places (or you can just modify this PR directly).
Once everything is addressed, I can add some bullet points in NEWS and bump the package version (if necessary).
Close #47, close #48.
Examples for
pivot_longer
Created on 2022-07-28 by the reprex package (v2.0.1)
Examples for
pivot_wider()
Created on 2022-07-28 by the reprex package (v2.0.1)