>> mywords<- c("harry","met","sally","subway10","1800Movies","12345", "not 
>> correct 123")
>> all.letters <- grep("^[[:alpha:]]*$", mywords)
>> all.numbers <- grep("^[[:digit:]]*$", mywords)  # numbers
>> mixed <- grep("^[[:digit:][:alpha:]]*$", mywords)

mywords<- c("harry","met","sally","subway10","1800Movies","12345",
"not correct 123", "")
mywords[grepl("^[[:digit:][:alpha:]]*$", mywords)]

So maybe you should use

mywords[grepl("^[[:digit:][:alpha:]]+$", mywords)]


And grepl is highly recommended over grep.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to