Is there an alternative to "mutate %>% select" sequence to insert a column& immediately reorder the inserted column

42 views
Skip to first unread message

Albert Lee

unread,
Feb 22, 2017, 12:30:15 PM2/22/17
to manipulatr
Hi,

I have been using `dplyr` for a long time, and I often find myself doing the following:

1. insert a column using `dplyr::mutate` function,  (i.e. mutate(df, id=gsub(....))
2. and immediately reorder it using `dplyr::select` function. (i.e .. %>% select(id, everything())

Is there an alternative way to do this? ideally, I would want `mutate` to have a flag that can help me insert a newly added column, but I don't think there is..because if it's flexibility of adding multiple columns at once. 

Any thoughts?

By the way, where's the best way to make a feature request for `dplyr`?

Hadley Wickham

unread,
Feb 24, 2017, 12:54:13 PM2/24/17
to Albert Lee, manipulatr
To answer both your questions with one link:
https://github.com/hadley/dplyr/issues/2047 ;)
Hadley
> --
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to manipulatr+...@googlegroups.com.
> To post to this group, send email to manip...@googlegroups.com.
> Visit this group at https://groups.google.com/group/manipulatr.
> For more options, visit https://groups.google.com/d/optout.



--
http://hadley.nz
Reply all
Reply to author
Forward
0 new messages