Description Usage Arguments Value Examples
The function splits grouped data and optional covariates into individual data.
Two types of grouped data are managed by splitbin
:
Grouped data with weights;
Grouped data of form “cbind(success, failure)”.
When weights, successes or failures involve non-integer numbers, these numbers are rounded before splitting.
1 2 |
formula |
A formula. The left-hand side represents grouped data. The right-hand side defines the covariates. See examples for syntax. |
data |
A data frame where all the variables described in |
id |
An optional character string naming the identifier (= grouping factor). Default to “idbin”. |
A data frame built according to the formula and function used in the call.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # Grouped data with weights
tmp <- data.frame(
success = c(0, 1, 0, 1),
f1 = c("A", "A", "B", "B"),
f2 = c("C", "D", "C", "D"),
n = c(4, 2, 1, 3)
)
tmp
splitbin(formula = n ~ f1, data = tmp)$tab
splitbin(formula = n ~ f1 + f2 + success , data = tmp)$tab
# Grouped data of form "cbind(success, failure)"
tmp <- data.frame(
success = c(4, 1),
failure = c(1, 2),
f1 = c("A", "B"),
f2 = c("C", "D")
)
tmp$n <- tmp$success + tmp$failure
tmp
splitbin(formula = cbind(success, failure) ~ 1, data = tmp)$tab
splitbin(formula = cbind(success, failure) ~ f1 + f2, data = tmp)$tab
splitbin(formula = cbind(success, n - success) ~ f1 + f2, data = tmp)$tab
splitbin(formula = cbind(success, n - 0.5 * failure - success) ~ f1 + f2,
data = tmp)$tab
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.