Hey! Thank you for taking the time! This sounds pretty familiar, I guess the main challenge pops up at step (3). The op in this thread used `ìfelse()``to work around some of this.
Still though, given his data, I'd be great if you could do something like this:
library(dplyr, warn.conflicts = FALSE)
my.df <- data.frame(aa=factor(c(1:24)),
bb=factor(rep(c(1:6), each=4)),
cc=factor(rep(c(1,2), each=4, times=3)),
dd=c(11:14, 21:24, 31:34, 41:44, 51:54, 61:64),
desired=c(11:14, 24:21, 31:34, 44:41, 51:54, 64:61))
my.df %>%
group_by(bb) %>%
arrange_if(cc == 2, ...)
Do you think scoped dplyr
verbs with custom functions for .predicate
and .funs
could handle situations like this? I'm finding it really hard to find any good tutorials on scoped verbs.