jwutil (version 1.2.3)

fix_na_ish: Fix NA-like strings to be NA (or other value of choice)

Description

Fix NA-like strings to be NA (or other value of choice)

Usage

fix_na_ish(x, extra_na = NULL, new_val = NA)

Arguments

x

data frame

extra_na

Additional values to consider equivalent to NA

new_val

New value to be used instead of NA-ish values, default is NA

Examples

Run this code
# NOT RUN {
df <- data.frame(
  a = c("NA", "n/a", 1, NA),
  b = c("three", "na", NaN, "  N/A "),
  stringsAsFactors = FALSE
)
df
fix_na_ish(df)
fix_na_ish(df, extra_na = "three", new_val = "0")
# }

Run the code above in your browser using DataCamp Workspace