Learn R Programming

extras (version 0.2.0)

fill_na: Fill Missing Values

Description

Fills all of an object's missing values while preserving the object's dimensionality and class.

Usage

fill_na(x, value, ...)

# S3 method for logical fill_na(x, value = FALSE, ...)

# S3 method for integer fill_na(x, value = 0L, ...)

# S3 method for numeric fill_na(x, value = 0, ...)

# S3 method for character fill_na(x, value = "0", ...)

Arguments

x

An object.

value

A scalar of the value to replace values with.

...

Other arguments passed to methods.

Value

The modified object.

Methods (by class)

  • logical: Fill Missing Values for logical Objects

  • integer: Fill Missing Values for integer Objects

  • numeric: Fill Missing Values for numeric Objects

  • character: Fill Missing Values for character Objects

Details

It should only be defined for objects with values of consistent class ie not standard data.frames.

See Also

Other fill: fill_all()

Examples

Run this code
# NOT RUN {
# logical
fill_na(c(TRUE, NA))

# integer
fill_na(c(1L, NA), 0)

# numeric
fill_na(c(1, NA), Inf)

# character
fill_na(c("text", NA))
fill_na(matrix(c("text", NA)), value = Inf)
# }

Run the code above in your browser using DataLab