SyntaxFix
Write A Post
Hire A Developer
Questions
You could get rid of all the letters too:
as.numeric(gsub("[[:alpha:]]", "", years))
Likely this is less generalizable though.