I have txt file with the following format:
(4, 'AF', 'AFG', 'Afghanistan'),
(248, 'AX', 'ALA', 'Aland Islands'),
.
.
.
I want to extract the number and the country. My idea is to use gsub
with "[^0-9]"
to find the number and something like tail(strsplit())
to extract the last word, after offcure I have removed all the special characters. Is there a a quicker way?
Data:
structure(list(V1 = c("(4, 'AF', 'AFG', 'Afghanistan'),", "(248, 'AX', 'ALA', 'Aland Islands'),",
"(8, 'AL', 'ALB', 'Albania'),", "(12, 'DZ', 'DZA', 'Algeria'),",
"(16, 'AS', 'ASM', 'American Samoa'),", "(20, 'AD', 'AND', 'Andorra'),"
)), .Names = "V1", row.names = c(NA, 6L), class = "data.frame")