new_category: Append universe with new category

View source: R/new_category.R

new_categoryR Documentation

Append universe with new category

Description

This appends an existing universe object with a new weighting category.

Usage

new_category(universe, name, groups, targets)

Arguments

universe

Output object from universe().

name

The name of the weighting category matching the name of the corresponding variable in the data to be weighted.

groups

A vector of the groups in the weighting category.

targets

A vector of the desired proportions of the groups. These targets will be automatically re-proportioned to sum to 1 if necessary.

Value

A list with special class universe.

Examples

uni <- universe(
    data = mtcars,

    category(
        name = "vs",
        groups = c(0, 1),
        targets = c(1/2, 1/2)
    )
)

new_category(
    universe = uni, 
    name = "am",
    groups = c(0, 1),
    targets = c(1/3, 2/3)
)


ttrodrigz/iterake documentation built on March 27, 2024, 12:48 a.m.