| setNA {simFrame} | R Documentation |
Generic function for inserting missing values into data.
setNA(x, control, ...) ## S4 method for signature 'data.frame, NAControl': setNA(x, control, i)
x |
the data in which missing values should be inserted. |
control |
a control object inheriting from the virtual class
"VirtualNAControl" or a character string specifying such a control
class (the default being "NAControl"). |
i |
an integer giving the element or row of the slot NArate of
control to be used as missing value rate(s). |
... |
if control is a character string or missing, the slots of
the control object may be supplied as additional arguments. |
In order to extend the framework by a user-defined control class
"MyNAControl" (which must extend "VirtualNAControl"), a method
setNA(x, control, i) with signature 'data.frame, MyNAControl'
needs to be implemented.
A data.frame containing the data with missing values. For every
target variable, a logical variable indicating the observations set to
NA is added to the data.frame. The names of these columns start
with a dot, followed by the name of the corresponding target variable (e.g.,
if missing values are generated in column "foo", a column
".foo" is added).
Andreas Alfons, alfons@statistik.tuwien.ac.at
data(eusilc)
sam <- draw(eusilc[, c("id", "age", "eqIncome")], size = 25)
## missing completely at random
setNA(sam, target = "eqIncome", NArate = 0.2)
## missing at random
setNA(sam, target = "eqIncome", NArate = 0.2, aux = "age")
## missing not at random
setNA(sam, target = "eqIncome", NArate = 0.2, aux = "eqIncome")