Learn R Programming

simPop (version 0.2.6)

manageSynthPopObj: get and set variables from population or sample data stored in an object of class synthPopObj.

Description

This functions allows to get or set variables in slots pop and sample of synthPopObj-objects. This is a utility function that is useful for writing custom wrapper functions.

Usage

manageSynthPopObj(x, var, sample=FALSE, set=FALSE, values=NULL)

Arguments

x
an object of class synthPopObj.
var
character vector of length 1; variable name that should be set or extracted.
sample
a logical indicating whether var should be extracted/set from slot 'sample' (TRUE) or slot 'pop' (FALSE).
set
logical; if TRUE, argument 'values' is set to either the sample or population data stored in 'x', depending on argument 'sample'. If FALSE, the desired variable given by 'var' is returned from either the sample or the pop slot of 'x'.
values
vector; if 'set' is TRUE, then this vector is used to update the variable of sample or population data depending of choice of argument 'sample'.

Value

  • An object of class synthPopObj (if 'set' is TRUE) or a vector (if 'set' is FALSE).

Examples

Run this code
data(eusilcS)
inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize", strata="db040",
  weight="db090")
synthPopObj <- simStructure(data=inp, method="direct", basicHHvars=c("age", "rb090"))

head(manageSynthPopObj(synthPopObj, var="age", sample=FALSE, set=FALSE))
head(manageSynthPopObj(synthPopObj, var="age", sample=TRUE, set=FALSE))

Run the code above in your browser using DataLab