fill.missing {nbpMatching}R Documentation

Data Imputation

Description

The fill.missing function uses the transcan function from the Hmisc package to impute values for the given data.frame.

Usage

fill.missing(x, seed = 101, simplify = TRUE, idcol = "id", ...)

Arguments

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 transcan.

Details

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.

Value

data.frame with imputed values

Author(s)

Cole Beck

See Also

transcan

Examples


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)


[Package nbpMatching version 1.5.5 Index]