-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
Allow named character vector in select
, to rename variables
#512
Conversation
Co-authored-by: Etienne Bacher <[email protected]>
Co-authored-by: Etienne Bacher <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, can you also add tests for:
- what happens when the new name already exists in the data?
- what happens if the new name is used in
exclude
?
It can't already exist in the data, because only the selected variables are returned. Thus, the case would be that a new name is chosen twice or more often. I'd say this should give an error?
What would you suggest? Check earlier and also exclude those variables? |
Agreed, I'm fine with the current changes
My second point was more about whether the following works, and it does: library(datawizard)
data_select(head(mtcars), c(drat = "mpg"), exclude = "drat")
#> drat
#> Mazda RX4 21.0
#> Mazda RX4 Wag 21.0
#> Datsun 710 22.8
#> Hornet 4 Drive 21.4
#> Hornet Sportabout 18.7
#> Valiant 18.1 We could add a test for this situation (if you agree with the current behavior) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from adding a test as mentioned in my comment above, this looks good to me, thanks!
Co-authored-by: Etienne Bacher <[email protected]>
Co-authored-by: Etienne Bacher <[email protected]>
Co-authored-by: Etienne Bacher <[email protected]>
Created on 2024-06-07 with reprex v2.1.0