recode_missing: recode_missing

Description Usage Arguments Value See Also Examples

View source: R/recode_missing.R

Description

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.

Usage

1
recode_missing(df, na_val)

Arguments

df

data frame

na_val

value to replace with NA

Value

data frame with missing value recoded to NA

See Also

Other functions for recoding missing values: recode_key

Examples

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)

HallLab/clarite documentation built on Oct. 27, 2020, 6:27 p.m.