splitbin: Split Grouped Data Into Individual Data

Description Usage Arguments Value Examples

Description

The function splits grouped data and optional covariates into individual data. Two types of grouped data are managed by splitbin:

When weights, successes or failures involve non-integer numbers, these numbers are rounded before splitting.

Usage

1
2
  splitbin(formula, data, id = "idbin")
  

Arguments

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 formula are found.

id

An optional character string naming the identifier (= grouping factor). Default to “idbin”.

Value

A data frame built according to the formula and function used in the call.

Examples

 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

tdisplay documentation built on May 2, 2019, 4:46 p.m.