Say I have a string like this :
years<-c("IMG_Sr 179 P.jpg", "IMG_Sr 18 L (2).jpg", "IMG_Sr 182 P.jpg")
The output I expect from this is :
c(179, 18,182)
What can I do for this?
Say I have a string like this :
years<-c("IMG_Sr 179 P.jpg", "IMG_Sr 18 L (2).jpg", "IMG_Sr 182 P.jpg")
The output I expect from this is :
c(179, 18,182)
What can I do for this?
If your desired output is the only part of the string that is a number surrounded by spaces then you can use:
gsub(".* (\\d*) .*", "\\1", years)