Is there a function to find all lower case letters in a character vector?
问题 I just wrote one, but I was wondering if one already exists in R. Here's the function BTW (suggestions for improvement are welcome): set.seed(50) x <- sample(c(letters, LETTERS), 7) is.lower <- function(x) { unlist(sapply(x, function(x2) {x2 %in% letters})) } is.lower(x) 回答1: grepl("[a-z]",x) for example? > grepl("[a-z]",x) [1] FALSE TRUE TRUE FALSE TRUE TRUE FALSE And why make it difficult? > x %in% letters [1] FALSE TRUE TRUE FALSE TRUE TRUE FALSE No need to make your own function. 回答2: