Replaces NAs in a numeric vector with the grouped medians of the non-NA values.
Groups are defined by the f argument.
Arguments
- x
A numeric vector
- f
A grouping variable, of the same length of
x, that specifies the group that each value ofxbelongs to. This will be coerced to a factor.- skip_f_na
If
TRUE, will work around anyNAs inf(the corresponding values ofxwill be excluded from the imputation and returned unaltered). Else ifFALSE, will cause an error.