Learn R Programming

extras (version 0.7.3)

fill_all: Fill All Values

Description

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

Usage

fill_all(x, value, ...)

# S3 method for logical fill_all(x, value = FALSE, nas = TRUE, ...)

# S3 method for integer fill_all(x, value = 0L, nas = TRUE, ...)

# S3 method for numeric fill_all(x, value = 0, nas = TRUE, ...)

# S3 method for character fill_all(x, value = "0", nas = TRUE, ...)

Value

The modified object.

Arguments

x

An object.

value

A scalar of the value to replace values with.

...

Other arguments passed to methods.

nas

A flag specifying whether to also fill missing values.

Methods (by class)

  • fill_all(logical): Fill All for logical Objects

  • fill_all(integer): Fill All for integer Objects

  • fill_all(numeric): Fill All for numeric Objects

  • fill_all(character): Fill All 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_na()

Examples

Run this code

# logical
fill_all(c(TRUE, NA, FALSE))
fill_all(c(TRUE, NA, FALSE, nas = FALSE))
fill_all(c(TRUE, NA, FALSE, value = NA))

# integer
fill_all(matrix(1:4, nrow = 2), value = -1)

# numeric
fill_all(c(1, 4, NA), value = TRUE)
fill_all(c(1, 4, NA), value = TRUE, nas = FALSE)

# character
fill_all(c("some", "words"), value = TRUE)

Run the code above in your browser using DataLab