fill.missing | R Documentation |
The fill.missing function uses the transcan
function from the
Hmisc package to impute values for the given data.frame.
fill.missing(x, seed = 101, simplify = TRUE, idcol = "id", ...)
x |
A data.frame object. It should have missing values. |
seed |
Seed provided for random-number generation. Default value of 101. |
simplify |
logical: whether to remove duplicate missingness columns. |
idcol |
An integer value or character string. Indicates the column containing IDs, specified as column index or column name. Defaults to "id", or NA, when not found. |
... |
Additional arguments, potentially passed to |
The fill.missing function will fill the missing values within a data.frame
with the values imputed with the transcan
function. An idcol may be
specified to prevent including the use of IDs in the imputation. In addition
for every column that contains missing data, a new column will be attached to
the data.frame containing an indicator of missingness. A "1" indicates that
the value was missing and has been imputed.
data.frame with imputed values
Cole Beck
transcan
set.seed(1)
df <- data.frame(id=LETTERS[1:25], val1=rnorm(25), val2=rnorm(25))
df[sample(seq_len(nrow(df)), ceiling(nrow(df)*0.1)), 2] <- NA
df <- fill.missing(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.