I have a vector filled with strings of the following format:
the first entries of the vector looks like
Since this is fixed format, why not use substr? year1 is extracted using substr(s,1,4), id1 is extracted using substr(s,9,9) and the id2 as as.numeric(substr(s,10,13)). In the last case I used as.numeric to get rid of the zeroes.
year1
substr(s,1,4)
id1
substr(s,9,9)
id2
as.numeric(substr(s,10,13))
as.numeric