Replaces missing values in an array of numeric values.

Description

Replaces missing values in an array of numeric values.

Usage

1
2
3
4
5
6
7
## S3 method for class 'numeric'
CleanNaFromContinuous(x, method="median", replacement.value=NULL, 
  return.replacement=FALSE, ...)
  
## S3 method for class 'POSIXct'
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.

Details

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

Value

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

Author(s)

Justin Hemann <support@causata.com>

Examples

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

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.