test if elements of a character vector contain letters
On Tue, Aug 7, 2012 at 10:26 PM, Marc Schwartz <marc_schwartz at me.com> wrote:
since there are alpha-numerics present, whereas the first option will:
grepl("[^[:alnum:]]", "ab%")
[1] TRUE So, use the first option.
And I should start reading more carefully. The above works fine for me.
I ended up defining the following wrappers:
is_alpha <- function(x) {grepl("[[:alpha:]]", x)} ##Alphabetic characters
is_digit <- function(x) {grepl("[[:digit:]]", x)} ##Digits
is_alnum <- function(x) {grepl("[[:alnum:]]", x)} ##Alphanumeric characters
is_punct <- function(x) {grepl("[[:punct:]]", x)} ##Punctuation characters
is_notalnum <- function(x) {grepl("[^[:alnum:]]", x)}
##Non-Alphanumeric characters
Thanks again
Liviu