fill_na: Fill Missing Values

Description Usage Arguments Value Methods (by class) See Also Examples

View source: R/fill-na.R

Description

Fills an object's missing values while preserving the object's class.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
fill_na(x, value, ...)

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

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

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

## S3 method for class '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)

See Also

Other fill: fill_all()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# 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)

extras documentation built on Oct. 23, 2020, 6:17 p.m.