-1
I have a variable - (Municipality), which brings me the result (Açucena - MG). How do I separate in R the Municipality of the State?
library(sidrar)
Tab1612SojaRend <-get_sidra(1612,variable = 112, period = c("last" = 22),geo ="City",
classific = 'c81',geo.filter = list("Region" = 3),
category = list(2713))
head(Tab1612SojaRend)
$`Abadia dos Dourados - MG`
Município (Código) Município Ano (Código) Ano
2 3100104 Abadia dos Dourados - MG 1996 1996
3 3100104 Abadia dos Dourados - MG 1997 1997
4 3100104 Abadia dos Dourados - MG 1998 1998
5 3100104 Abadia dos Dourados - MG 1999 1999
6 3100104 Abadia dos Dourados - MG 2000 2000
7 3100104 Abadia dos Dourados - MG 2001 2001
8 3100104 Abadia dos Dourados - MG 2002 2002
9 3100104 Abadia dos Dourados - MG 2003 2003
10 3100104 Abadia dos Dourados - MG 2004 2004
11 3100104 Abadia dos Dourados - MG 2005 2005
12 3100104 Abadia dos Dourados - MG 2006 2006
13 3100104 Abadia dos Dourados - MG 2007 2007
14 3100104 Abadia dos Dourados - MG 2008 2008
15 3100104 Abadia dos Dourados - MG 2009 2009...
You could post the code to us?
– Albertt Santos
strsplit('Açucena - MG', ' - ')
.– Rui Barradas
My comment above only works if
class(Municipio)
for"character"
. If it is"factor"
has to bestrsplit(as.character(Municipio), ' - ')
.– Rui Barradas
Thanks Rui, only I have a problem with '-' separation, because there are some municipalities that have '-'. Don’t have any function, like the right, left formula of excel? , that then I would ask the last 2.
– Everton Toledo
Albertt, I didn’t put the code in because it’s too big
– Everton Toledo
Note that separation is not
'-'
, has spaces before and after,' - '
. So it must work even if the city has'-'
space-free.– Rui Barradas