blank_to_missing: Convert whitespace to a missing value

View source: R/transforms_text.R

blank_to_missingR Documentation

Convert whitespace to a missing value

Description

Convert whitespace to a missing value

Usage

blank_to_missing(x, missing_value = NA)

Arguments

x

A character vector

missing_value

Defaults to NA, but can be used to convert all whitespace values to a single character value

Details

Given a character vector, this function replaces entries that contain *only* whitespace with the missing_value provided. Entries such as empty strings "", any number of spaces " ", " ", tab ("\t"), newline ("\n"), and carriage return ("\r") are converted to the missing_value.

Value

the modified character vector

Examples

blank_to_missing(c("A","B","C"," ", "   ", "\t", " he", "hi\t",123,"\n", "two\nlines", ""))

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.