Apply a function for imputation over rows, columns or combinations of both
A data frame or matrix with missing values.
The function to be applied for imputation.
A string specifying the values used for imputation (see details).
Further arguments passed to
The functionality of
apply_imputation is inspired by the
apply function. The function applies a function
FUN to impute the missing values in
FUN must be a
function, which takes a vector as input and returns exactly one value. The
type is comparable to
MARGIN argument. It specifies the values that are used for the
calculation of the imputation values. For example,
type = "columnwise"
FUN = mean will impute the mean of the observed values in a column
for all missing values in this column. In contrast,
type = "rowwise"
FUN = mean will impute the mean of the observed values in a row
for all missing values in this row.
List of all implemented
"columnwise" (the default): imputes column by column; all observed
values of a column are given to
FUN and the returned value is used
as the imputation value for all missing values of the column.
"rowwise": imputes row by row; all observed values of a row are given
FUN and the returned value is used as the imputation value for all
missing values of the row.
"total": All observed values of
ds are given to
the returned value is used as the imputation value for all missing values of
"Winer": The mean value from "columnwise" and "rowwise" is used as the imputation value.
"Two-way": The sum of the values from "columnwise" and "rowwise" minus "total" is used as the imputation value.
If no value can be given to
FUN (for example, if no value in a column
is observed and
type = "columnwise"), then a warning will be issued
and no value will be imputed in the corresponding column or row.
An object of the same class as
ds with imputed missing values.
If you use tibbles and an error like ‘Lossy cast from 'value' double to integer’ occurs, you will first need to convert all integer columns with missing values to double. Another solution is to convert the tibble with as.data.frame() to a data frame. The data frame will automatically convert integer columns to double columns, if needed.
Beland, S., Pichette, F., & Jolani, S. (2016). Impact on Cronbach's alpha of simple treatment methods for missing data. The Quantitative Methods for Psychology, 12(1), 57-73.
1 2 3 4 5 6
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.