impute-constant {na.tools} | R Documentation |
Impute by Constant Value
Replaces NA
s by a constant
Description
Impute by Constant Value
Replaces NA
s by a constant
Usage
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 |
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
-
na.replace()
the underlying function that performs the replacement.
Examples
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
[Package na.tools version 0.3.1 Index]