powered by
This provides a convenient way to recode "NA" as another value for instance "NaN", "n/a" or any other value a user wishes to use.
recode_na_as( df, value = 0, subset_cols = NULL, pattern_type = NULL, pattern = NULL, case_sensitive = FALSE, ... )
An object of the same type as x with NAs replaced with the desired value.
A data.frame object for which recoding is to be done.
The value to convert to `NA`. We can for instance change "n/a" to `NA` or any other value.
An optional character vector to define columns for which changes are required.
One of contains', 'starts_with' or 'ends_with'.
A character pattern to match
Defaults to FALSE. Patterns are case insensitive if TRUE
Other arguments to other functions
head(recode_na_as(airquality, "n/a")) head(recode_na_as(airquality, subset_cols = "Ozone", value = "N/A")) head(recode_na_as(airquality, value=0, pattern_type="starts_with", pattern="Solar"))
Run the code above in your browser using DataLab