search for: is_letter

Displaying 1 result from an estimated 1 matches for "is_letter".

2012 Aug 06
3
test if elements of a character vector contain letters
..."21" "22" "23" "24" "25" "26" How do you test whether the elements of the vector contain at least one letter (or at least one digit) and obtain a logical vector of the same dimension? I came up with the following awkward function: is_letter <- function(x, pattern=c(letters, LETTERS)){ sapply(x, function(y){ any(sapply(pattern, function(z) grepl(z, y, fixed=T))) }) } > is_letter(x) a10 b7 c2 d3 e6 f1 g5 h8 i9 j4 k l m n o TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE...