check_attributes: Attributes check

View source: R/designs_helpers.R

check_attributesR Documentation

Attributes check

Description

Verification that all desired characteristics are present in $Z$. This is an internal function which serves to simplify concatenation of multiple $Z$ when alternatives have different attributes.

Usage

check_attributes(Z, attributes)

Arguments

Z

Input data.frame Z

attributes

Desired vector of attributes to be present in Z.

Value

Z With missing attributes filled with NA's.

Examples

# Create alternatives
alt1 <- alternative$new()
alt1$add_attributes(Quality = runif(min = 0, max = 1), Price = rnorm(mean = 5))
alt2 <- alternative$new()
alt2$add_attributes(Size = runif(min = 0, max = 1), Price = rnorm(mean = 6))

# Regroup alternatives into design
edesign <- experimental_design$new(alternatives = list(alt1, alt2))
Z <- designs_r(edesign, n = 1)

# Querry object
attr <- edesign$get_attributes()
Z <- check_attributes(Z, attr)

nikitagusarov/dcesimulatr documentation built on Jan. 7, 2023, 4:27 p.m.