fill_na: Modify vectors, dataframes, or matrices to fill missing...

Description Usage Arguments Value See Also Examples

Description

This is a wrapper of base::replace() with a simplified interface and a name that target the specific job of filling NA's. See also tidyr::replace_na and dplyr::coalesce.

Usage

1
fill_na(x, filler = 0)

Arguments

x

A dataframe.

filler

A filler; whatever you want to replace NA's with.

Value

A modified version of x.

See Also

Other general functions to edit data in place: lookup

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x <- data.frame(x = c(NA, 1), y = c("a", NA), stringsAsFactors = FALSE)

a_dataframe <- x
fill_na(a_dataframe)
fill_na(a_dataframe, "")
fill_na(a_dataframe, "missing")

a_matrix <- as.matrix(x)
fill_na(a_matrix)

a_vector <- x$x
fill_na(a_vector)

a_list <- list(x, x, x)
lapply(a_list, fill_na)

forestgeo/fgeo.misc documentation built on June 23, 2019, 6:26 p.m.