deterge: Convert (and possibly clean) a vector

detergeR Documentation

Convert (and possibly clean) a vector

Description

Cast values to desired data type.

Usage

deterge_to_double(x, bound_lower, bound_upper)
deterge_to_integer(x, bound_lower, bound_upper)
deterge_to_ascii(x, substitution_character)

Arguments

x

The input vector that needs to be cast/converted. Required.

bound_lower

Elements below this inclusive threshold will be set to NA.

bound_upper

Elements above this inclusive threshold will be set to NA.

substitution_character

If the character does not have an equivalent in ASCII, replace it with this character. Defaults to a question mark (i.e., '?').

Details

The functions deterge_to_double() and deterge_to_integer() accept character representations of a number, and return a numeric or integer vector. Elements outside bound_lower and bound_upper are converted to NA_real_/NA_integer_.

The function deterge_to_ascii() accepts a character vector and returns a character vector. The encoding is changed to ASCII. Individual elements are allowed to be NA_character_.

Value

An array of values.

Author(s)

Will Beasley

See Also

The real work in deterge_to_ascii() is performed by base::iconv(). base::iconv(x=x, from="latin1", to="ASCII//TRANSLIT", sub=substitution_character)

Examples

library(OuhscMunge)
deterge_to_double(c(NA, 1:10), 4, 8)
deterge_to_integer(c(NA, 1:10), 4L, 8L)

x <- c("Ekstr\xf8m", "J\xf6reskog", "bi\xdfchen Z\xfcrcher")
deterge_to_ascii(x)

OuhscBbmc/OuhscMunge documentation built on Dec. 5, 2024, 4:34 a.m.