within_group: Execute code within a group

Description Usage Arguments Value See Also Examples

View source: R/ops.R

Description

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

1
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

1
2
3
4
5
6
7
8
9
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()

multiplyr documentation built on May 30, 2017, 12:09 a.m.