Learn R Programming

Causata (version 4.2-0)

CleanNaFromContinuous: Replaces missing values in an array of numeric values.

Description

Replaces missing values in an array of numeric values.

Usage

"CleanNaFromContinuous"(x, method="median", replacement.value=NULL, return.replacement=FALSE, ...) "CleanNaFromContinuous"(x, method="median", replacement.value=NULL, return.replacement=FALSE, ...)

Arguments

x
An array of numerical (continuous) values and missing values.
method
Sets the method used to replace missing values. Valid values are "median" and "mean".
replacement.value
If this argument is not NULL then missing values will be replaced with the value provided instead of a mean or median.
return.replacement
If FALSE then an array is returned with missing values replaced. If TRUE then a list is returned with the array and the replacement value.
...
Unused arguments for other methods.

Value

Returns an array with missing values replaced. Optionally a list can be returned with the array and the replacement value.

Details

The default behavior is that missing numeric values are replaced with the median.

Examples

Run this code
# numeric, median is 2, mean is 3.7
x <- c(NA, 1,1.5,2,3,11)
CleanNaFromContinuous(x)

Run the code above in your browser using DataLab