Description Usage Arguments Details Value Author(s) Examples
Modifies a kott.design object by adding new variables to it.
1 | kott.addvars(deskott, ...)
|
deskott |
Object of class |
... |
|
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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(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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.