Cast values to desired data type.
deterge_to_double(x, bound_lower, bound_upper)
deterge_to_integer(x, bound_lower, bound_upper)
deterge_to_ascii(x, substitution_character)
The input vector that needs to be cast/converted. Required.
Elements below this inclusive threshold will be set to NA
.
Elements above this inclusive threshold will be set to NA
.
If the character does not have an equivalent in ASCII, replace it with this character. Defaults to a question mark (i.e., '?').
An array of values.
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_
.
The real work in deterge_to_ascii()
is performed by base::iconv()
.
base::iconv(x=x, from="latin1", to="ASCII//TRANSLIT", sub=substitution_character)
library(OuhscMunge)
deterge_to_double(c(NA, 1:10), 4, 8)
#> [1] NA NA NA NA 4 5 6 7 8 NA NA
deterge_to_integer(c(NA, 1:10), 4L, 8L)
#> [1] NA NA NA NA 4 5 6 7 8 NA NA
x <- c("Ekstr\xf8m", "J\xf6reskog", "bi\xdfchen Z\xfcrcher")
deterge_to_ascii(x)
#> [1] "Ekstrom" "J\"oreskog" "bisschen Z\"urcher"