I'm relatively new to regex and I'm at a dead end. I have a data frame with a column that looks like this:
year1
GMM14_2000_NGVA
GMM14_2001_NGVA
GMM14_2002_NGVA
...
GMM14_2014_NGVA
I am trying to extract a year in the middle of a line (2000,2001, etc.). This is my code so far
gsub("[^0-9]","",year1))
which returns a number, but also returns 14, which is part of the string:
142000
142001
Any idea on how to exclude 14 from the template or how to extract year information more efficiently?
thanks
source
share