replace_na.: Replace missing values

Description Usage Arguments Examples

View source: R/replace_na.R

Description

Replace NAs with specified values

Usage

1

Arguments

.x

A data.frame/data.table or a vector

replace

If .x is a data frame, a list() of replacement values for specified columns. If .x is a vector, a single replacement value.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
test_df <- data.table(
  x = c(1, 2, NA),
  y = c(NA, 1, 2)
)

# Using replace_na.() inside mutate.()
test_df %>%
  mutate.(x = replace_na.(x, 5))

# Using replace_na.() on a data frame
test_df %>%
  replace_na.(list(x = 5, y = 0))

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.