This is the mainstay of parallel computation for a data frame. This will
execute the specified expression within each group. Each group will have a
persistent environment, so that variables created in that environment can
be referred to by, for example, later calls to summarise. This environment
contains active bindings to the columns of that data frame.
Usage
within_group(.self, expr)
Arguments
.self
Data frame
expr
Code to execute
Value
Data frame
See Also
Other data manipulations: mutate,
nsa, reduce,
summarise, transmute,
within_node
Examples
dat <- Multiplyr (G = rep(c("A", "B"), each=50),
m = rep(c(5, 10), each=50),
alloc=1)
dat %>% group_by (G) %>% mutate (x=rnorm(length(m), mean=m))
dat %>% within_group ({
mdl <- lm (x ~ 1)
})
dat %>% summarise (x.mean = coef(mdl)[[1]])
dat %>% shutdown()