impute-constant: Impute by Constant Value Replaces 'NA's by a constant

Description Usage Arguments Details Value See Also Examples

Description

Impute by Constant Value

Replaces NAs by a constant

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
na.constant(.x, .na)

na.inf(.x)

na.neginf(.x)

na.true(.x)

na.false(.x)

na.zero(.x)

Arguments

.x

vector; of values to have the NA

.na

scalar to use as replacement.

Details

These functions replace ALL NA values in x with an scalar value specified by.na.

na.constant replaces missing values with a scalar constant. It is a wrapper around na.replace() but permits .na to only be a scalar.

na.inf and na.neginf replace all missing values with Inf and -Inf repectively. '.

na.true and na.false replace missing values with TRUE and FALSE respectively.

na.zero replaces missing values with 0 which gets coerced to the class(x) as needed.

Value

A vector with the type and length of x with all missing values replaces by .na.

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
  na.constant( c(1,NA,2), -1 )
 
  na.inf( c( 1, 2, NA, 4) )
  na.neginf( c( 1, 2, NA, 4) ) 
  
  na.true( c(TRUE, NA_logical, FALSE) )   # T T F
  na.false( c(TRUE, NA_logical, FALSE) )  # T F F

 
           
  na.zero( c(1,NA,3) )  # 1 0 3 

 
           

na.tools documentation built on June 26, 2018, 5:02 p.m.