View source: R/groupAndRename.R
groupAndRename | R Documentation |
sdcMicroObj-class
or factor
or data.frame
If the input is an object of class sdcMicroObj-class
, the
specified factor-variable is recoded into a factor with less levels and
risk-measures are automatically recomputed.
groupAndRename(obj, var, before, after, addNA = FALSE)
obj |
object of class |
var |
name of the keyVariable to change |
before |
vector of levels before recoding |
after |
name of new level after recoding |
addNA |
logical, if TRUE missing values in the input variables are added to the level specified in argument |
If the input is of class data.frame
, the result is a data.frame
with
a modified column specified by var
.
If the input is of class factor
, the result is a factor
with different
levels.
the modified sdcMicroObj-class
Bernhard Meindl
Templ, M. and Kowarik, A. and Meindl, B. Statistical Disclosure Control for Micro-Data Using the R Package sdcMicro. Journal of Statistical Software, 67 (4), 1–36, 2015. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v067.i04")}
Templ, M. Statistical Disclosure Control for Microdata: Methods and Applications in R. Springer International Publishing, 287 pages, 2017. ISBN 978-3-319-50272-4. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-319-50272-4")} \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-319-50272-4")}
## for objects of class sdcMicro:
data(testdata2)
testdata2$urbrur <- as.factor(testdata2$urbrur)
sdc <- createSdcObj(testdata2,
keyVars=c('urbrur','roof','walls','water','electcon','relat','sex'),
numVars=c('expend','income','savings'), w='sampling_weight')
sdc <- groupAndRename(sdc, var="urbrur", before=c("1","2"), after=c("1"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.