I have a database with thousands of rows, but in one of the columns the data looks like this:
XLOCAL
Estirão do Equador, Rio Javari (04°27'S;71°30'W)
Alto Rio Paru de Oeste, Posto Tiriós (02°15'N;55°59'W)
Ipixuna do Pará, Rodovia Belém-Brasília km 92/93 (02°26'S;47°30'W)
Aurora do Pará, Rodovia Belém-Brasília km 86 (02°04'S;47°33'W)
I would like help to leave only the coordinates, removing all the texts, parentheses and semicolons. It would look like this:
XLOCAL
04°27'S 71°30'W
02°15'N 55°59'W
I tried using strings and gsub but I did not succeed. Example of what I tried.
df <- c("sdasdad (04°27'S;71°30'W)", "zxczxczcxz (01°40'N;51°23'W)")
grep("^([[:punct:]])", df, value=TRUE)
pattern <- "[[:alpha:]]"
gsub("^.[[:alpha:]]", df, fixed=F)
result
[1] " (04°27';71°30')" " (01°40';51°23')" #Reparem que ele removeu também "N", "S", "W" das coordenadas.
The database is a museum, they are not available online, you have to organize it to make it available online. Help me, there are thousands of lines to remove manually. Thank you very much in advance.