printable_ascii(x)character vectorlogical indicating which elements consist solely of printable ASCII characters.A-Z, a-z, 0-9 and the characters! "" # $ \% & ' ( ) * + , . / : ; < = > ? @ [ ] \\ ^ _ ` { | } ~ -}
Note that this excludes tab (as it is a control character).
Some algorithms (like soundex) are defined only on the printable ASCII character set. This excludes any character with accents for example. Translating accented characters to the non-accented ones is a form of transliteration. On many systems running R (but not all!) you can achieve this with
iconv(x,to="ASCII//TRANSLIT"),
where x is your character vector. See the documentation of iconv for details.
The stringi package (Gagolewski and Tartanus) should work on any system. The command
stringi::stri_trans_general(x,"Latin-ASCII") transliterates character vector x to ASCII.
}
# Control characters (like carriage return) are also excluded printable_ascii("abc\r")