if_na: Replace NA values with something else

View source: R/shorthands.R

if_naR Documentation

Replace NA values with something else

Description

Often, you want to substitute missing values with some implicit known value (e.g. if the question on number of sexual partners was skipped for sexually inactive people, you know the missing should turn into zero)

Usage

if_na(x, missing)

Arguments

x

the variable

missing

What to replace missing values with

Examples

number_of_sex_partners <- c(1, 3, 5, 10, NA, 29)
if_na(number_of_sex_partners, 0)

rubenarslan/formr documentation built on Feb. 7, 2025, 6:31 a.m.