formatNA: Missing Value Formatting

View source: R/utils.R

formatNAR Documentation

Missing Value Formatting

Description

Takes a numeric vector and replaces all missing codes with NA and returns a factor if the variable is categorical or a numeric variable if it's numeric.

Usage

formatNA(y, type = c("cat", "cont"), codes = c("", "Unk", "N/A"))

Arguments

y

a vector.

type

whether the variable is "cat" (categorical) or "cont" (continuous). Defaults to "cat".

codes

vector of missing codes to replace with NA

Value

A categorical or numerical vector with all missing formatted as NA.

Author(s)

Aline Talhouk, Derek Chiu

Examples

y <- c(1:10, "Unk", 12)
formatNA(y)

TalhoukLab/biostatUtil documentation built on April 14, 2025, 4:15 a.m.