agg_binomial | R Documentation |
A simple function for aggregating binomial data, from
a form where y
contains only 0
and 1
and X
could contain duplicated rows, into a format where
y
is the matrix of counted successes and failures
and X
does not contain duplicates. If X
contains
factor variables, the model matrix corresponding to X
will be returned.
agg_binomial(formula, data, as_list = TRUE)
formula |
a formula object defining the aggregation. |
data |
a |
as_list |
a logical giving if the return value
should be a |
A list
(or data.frame
) containing aggregated
binomial data with counted successes and failures.
set.seed(12345)
data <- data.frame(y = rbinom(50, 1, 0.7),
a = factor(sample(c(1, 2), 50, TRUE)),
b = factor(sample(c(1, 2, 3), 50, TRUE)))
agg_binomial(y ~ ., data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.