impute-constant {na.tools} | R Documentation |
NA
s by a constantImpute by Constant Value
Replaces NA
s by a constant
na.constant(.x, .na) na.inf(.x) na.neginf(.x) na.true(.x) na.false(.x) na.zero(.x)
.x |
vector; of values to have the |
.na |
scalar to use as replacement. |
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.
A vector with the type and length of x
with all missing values replaces
by .na
.
na.replace()
the underlying function that performs the replacement.
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