-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
mutate
superseding transmute
should allow ordering columns
#6861
Comments
This is one of the reasons why I still use |
Two very related PRs:
Extremely important paragraph:
So we should be extremely careful when considering if we want to make any changes here. #6035's big insight is that
I spent a lot of time thinking about those two PRs, and I still think the current implementation is solid theoretically, so I don't think this is a bug as much as some way to incorporate a separate idea from |
I've refreshed myself on the logic in #6035 (comment), and I am confident that the current implementation of A key principle is that only 1 argument should be able to affect the output ordering. As of right now, So, the only thing I think I can offer is a 5th variant of I feel like |
If As a second bit of reasoning, there's code clarity: I find (and I assume other readers of code are like me) that putting I miss my friend |
If |
How about adding another option: |
Just a quick comment to say that I second the idea of either adding an I am currently working on a a script that converts default data tables as generated from specific hardware to human-readable tables suitable for publication in reports. As such, column order is important. I would have used What is frustrating me is that columns that are carried across unchanged are staying in their original order, and any new columns (either renamed or calculated) are appended to the right in the order they are called. As a further example: > old <- data.frame(var1 = 1:5, var2 = 6:10, var3 = 11:15, var4 = 16:20, var100 = 101:105)
> old %>% mutate(
var1 = var1,
var2a = var2,
var3 = var3,
var4 = var4,
var5 = var4*2,
.keep = "none"
)
Where I expect the order of |
Precisely. New columns are appended to the right, but since we explicitly name every column we want, we should be able to control exactly how the columns end up like |
I learned about If the goal is to reduce the number of verbs, an alternative could be to add |
I recently noticed that
transmute
has been marked as superseded bymutate(.keep="none")
. However, it turned out thatmutate
doesn't replicate column ordering behavior oftransmute
, but does something odd:With more complex examples, the ordering becomes pretty confusing and difficult to explain. I'm guessing this may have to do with the
.keep = "used"
use case resorting things. For.keep = "none"
, explicit column ordering as given, replicating or approximatingtransmute
behavior, would be much more useful (e.g. order of first LHS mention or last LHS mention).The text was updated successfully, but these errors were encountered: