Description Usage Arguments Value See Also Examples
View source: R/recode_missing.R
Recode if there is one missing value for entire dataset
Empty strings ("") and "NA" will be replaced by NA regardless of keys
Note: Replaced values must be a factor, integer, or numeric (other values are ignored). Float values may fail to convert due to rounding.
1 | recode_missing(df, na_val)
|
df |
data frame |
na_val |
value to replace with NA |
data frame with missing value recoded to NA
Other functions for recoding missing values: recode_key
1 2 3 4 5 6 7 8 | # Create an example dataset
df <- data.frame("ID" = 1:3,
"Age" = c(21,15, 34),
"Name" = c("John","Jane", "Jill"),
"Value1" = c("a", "b", "NA"),
"Value2" = c(1, 2, 99))
# Recode 99 and "NA" to NA
recoded <- recode_missing(df, 99)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.