View source: R/impute_location_parameter.R
impute_median | R Documentation |
Impute an observed median value for every missing value
impute_median( ds, type = "columnwise", ordered_low = FALSE, convert_tibble = TRUE )
ds |
A data frame or matrix with missing values. |
type |
A string specifying the values used for imputation; one of: "columnwise", "rowwise", "total", "Two-Way" or "Winer" (see details). |
ordered_low |
Logical; used for the calculation of the median from ordered factors (for details see: median.factor). |
convert_tibble |
If |
This function behaves exactly like impute_mean
.
The only difference is that it imputes a median instead of a mean.
All type
s from impute_mean
are also implemented for
impute_median
.
They are documented in impute_mean
and
apply_imputation
.
The function median
is used for the calculation of
the median values for imputation.
An object of the same class as ds
with imputed missing values.
If you use tibbles and convert_tibble
is TRUE
the tibble is
first converted to a data frame, then imputed and converted back. If
convert_tibble
is FALSE
no conversion is done. However,
depending on the tibble and the package version of tibble you use,
imputation may not be possible and some errors will be thrown.
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.
apply_imputation
the workhorse for this function.
median
, median.factor
Other location parameter imputation functions:
impute_mean()
,
impute_mode()
ds <- data.frame(X = 1:20, Y = ordered(LETTERS[1:20])) ds_mis <- delete_MCAR(ds, 0.2) ds_imp <- impute_median(ds_mis) # completely observed columns can be of any type: ds_mis_char <- cbind(ds_mis, letters[1:20]) ds_imp_char <- impute_median(ds_mis_char)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.