I personally learned plyr prior to dplyr, and I'm trying to normalize my code into the dplyr syntax wherever possible, but I get stuck with the following use-case:
ddply(
.data = somedataframe,
.variables = c('var1', 'var2'),
.function =
function(thisdf){
...
}
)
Where the ... inside the function call is some arbitrarily complex modification of the dataframe. Note that the choice of ddply versus dlply (or anyother dxply) is purely for illustration. Does a function within dplyr exists (call it dplyr::f for the moment), that could also take an arbitrary modification function? For example:
somedataframe %>%
group_by(var1, var2) %>%
dplyr::f(.function = function(thisdf){ ... })
In my investigation of this functionality, all the examples that I could find were extremely simple summarise implementations of ddply.
group_by_mapthat attempt to cover this kind of thing. - jorangroup_mapand you can read about it here. The older way of doing this sort of thing in dplyr (that still works, I believe) isdo(). - joran