sanitizeNa: Sanitize NA values

sanitizeNaR Documentation

Sanitize NA values

Description

Standardize empty strings (""), character NAs ("NA"), and NULL values inside a character vector to NA_character_. Other atomic data types are returned unmodified.

Usage

sanitizeNa(object, ...)

## S4 method for signature 'DFrame'
sanitizeNa(object)

## S4 method for signature 'atomic'
sanitizeNa(object)

## S4 method for signature 'character'
sanitizeNa(object)

## S4 method for signature 'data.frame'
sanitizeNa(object)

## S4 method for signature 'factor'
sanitizeNa(object)

Arguments

object

Object.

...

Additional arguments.

Value

Modified object. Sanitized to contain proper NA values.

Note

Updated 2023-09-20.

Examples

## character ====
from <- as.character(c(1L, "x", "", "NA", "NULL"))
print(from)
to <- sanitizeNa(from)
print(to)

## DFrame ====
from <- S4Vectors::DataFrame(
    "a" = c("foo", ""),
    "b" = c(NA, "bar"),
    row.names = c("c", "d")
)
print(from)
to <- sanitizeNa(from)
print(to)

acidgenomics/brio documentation built on Feb. 1, 2024, 11:47 a.m.