0

I was writing some code that need to inspect individual characters in a input string. I want to know whether there were numbers in string, and use strsplit to split the character into list. Then, use any() to check the numbers (the limitation is that I can't use grepl :(

b<-"Idontknow456"
b<-strsplit(b,"")
length(b)
any(6%in%b)

c<-list("d","t","5")
length(c)
any(5%in%c)

the result

  1
  FALSE
  3
  TRUE

May I ask how should I modify my code, so that I can split individual characters to inspect them?

0 Answers0