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
After the post from Gabor Grothendieck post at the r-help mailing list
years<-c("20 years old", "1 years old") library(gsubfn) pat <- "[-+.e0-9]*\\d" sapply(years, function(x) strapply(x, pat, as.numeric)[[1]])