Learn R Programming

synthACS (version 1.7.1)

add_constraint: Add new constraint to constraint table

Description

Add a new constraint to the mapping between a given macro dataset (class "macroACS") and a matching micro dataset (class "micro_synthetic). May be called repeatedly to create a set of constraints.

Usage

add_constraint(
  attr_name = "variable",
  attr_totals,
  micro_data,
  constraint_list = NULL
)

Value

A list of constraints.

Arguments

attr_name

The name of the attribute, or variable, that you wish to constrain.

attr_totals

A named integer vector of counts per level of the new constraining attribute.

micro_data

The micro dataset, of class "micro_synthetic", for which you wish to add a constraint.

constraint_list

A list of prior constraints on the same dataset which you wish to add to. Defaults to NULL (ie. the default is that this is the first constraint.)

Examples

Run this code
if (FALSE) {
## assumes that you have a micro_synthetic dataset named test_micro and attribute counts
## named a,e,g respectively 
c_list <- add_constraint(attr_name= "age", attr_totals= a, micro_data= test_micro)
c_list <- add_constraint(attr_name= "edu_attain", attr_totals= e, micro_data= test_micro,
                        constraint_list= c_list)
c_list <- add_constraint(attr_name= "gender", attr_totals= g, micro_data= test_micro,
                         constraint_list= c_list)
}

Run the code above in your browser using DataLab