I have string like this:
years<-c(\"20 years old\", \"1 years old\")
I would like to grep only the numeric number from this vector. Expe
Here's an alternative to Arun's first solution, with a simpler Perl-like regular expression:
as.numeric(gsub("[^\\d]+", "", years, perl=TRUE))