Hi R users,
I'd like to know if anyone has come across problems wherein it was necessary
to check if strings contained all alphabets, some numbers or all numbers?

In my attempt to test if a string is numeric, alpha-numeric (also includes
if string is only alphabets) :

# Reproducible R code below
mywords<- c("harry","met","sally","subway10","1800Movies","12345")

mywords.alphanum
<-lapply(sapply(mywords,function(x)strsplit(x,NULL)),function(y)
ifelse(sum(is.na(sapply(y,as.numeric))) == 0 & length(y) >
0,"numeric","alpha-numeric"))

names(mywords.alphanum)[(which(mywords.alphanum == "numeric"))]


I understand that such "one-liners"  (the second line of code above) that
make multiple calls are discouraged, but I seem to find then fascinating.

Looking forward to alternate solutions/packages  for the above problem.

Thanks
Harsh Singhal

	[[alternative HTML version deleted]]


