kott.addvars {EVER} | R Documentation |
Modifies a kott.design object by adding new variables to it.
kott.addvars(deskott, ...)
deskott |
Object of class kott.design containing the replicated survey data. |
... |
tag = expr arguments defining columns to be added to deskott . |
This function adds to the data frame contained in deskott
the new variables defined by the tag = expr
arguments. A tag
can be specified either by means of an identifier or by a character string; expr
can be any expression that it makes sense to evaluate in the deskott
environment.
For each argument tag = expr
bound to the formal argument ...
the added column will have name given by the tag
value and values obtained by evaluating the expr
expression on deskott
. Any input expression unsupplied with a tag
will be ignored and will therefore have no effect on the kott.addvars
return value.
Variables to be added to the input replicated object have to be new: namely it is not possible to use kott.addvars
to modify the values in a pre-existing deskott
column.
An object of the same class of deskott
, containing new variables but supplied with exactly the same metadata.
Diego Zardetto
data(data.examples) # Creation of a kott.design object: kdes<-kottdesign(data=example,ids=~towcod+famcod,strata=~SUPERSTRATUM, weights=~weight,nrg=15) # Adding the new 'population' variable to estimate the number # of final units in the population: kdes2<-kott.addvars(kdes,population=1) kottby(kdes2,~population) # Recoding a qualitative variable: kdes2<-kott.addvars(kdes,agerange=as.factor(ifelse(kdes$age5c==1, "young","not-young"))) kottby(kdes2,~agerange,est="mean") kottby(kdes2,~income,~agerange,estimator="mean",conf.int=TRUE) # Algebraic operations on numeric variables: kdes2<-kott.addvars(kdes,q=income/z^2) kottby(kdes2,~q)