Learn R Programming

jwutil (version 1.2.3)

zero_na: Zero NA values in a data.frame

Description

Zero NA values in a data.frame, including cols and exluding ignore. Also does not replace Date or POSIXt fields.

Usage

zero_na(x, cols = names(x), ignore = character(), verbose = FALSE,
  na_ish = TRUE, new_val = 0)

Arguments

x

data.frame

cols

names of columns to work on, default is all columns

ignore

character vector of columns names to ignore

verbose

TRUE or FALSE

na_ish

Logical, default `TRUE` which will convert NA-like strings, too

new_val

`0`

Examples

Run this code
# NOT RUN {
d <- data.frame(1:5, 6:10, 11:15)
d[2, 3] <- NA
d[5, 2] <- NA
d[1, 1] <- NA
print(d)
zero_na(d)
d[1, 1] <- "NA"
zero_na(d, na_ish = TRUE)
# }

Run the code above in your browser using DataLab