Skip to content

Instantly share code, notes, and snippets.

@mvpsaraiva
Last active April 2, 2021 18:51
Show Gist options
  • Save mvpsaraiva/7a929bd1415d35899990bcad52ad47fa to your computer and use it in GitHub Desktop.
Save mvpsaraiva/7a929bd1415d35899990bcad52ad47fa to your computer and use it in GitHub Desktop.
Proposta de nova estrutura para munis_df
munis_df <- tribble(
~code_muni, ~abrev_muni, ~name_muni, ~abrev_estado,
2304400, "for", "Fortaleza", "CE",
3550308, "spo", "Sao Paulo", "SP",
3304557, "rio", "Rio de Janeiro", "RJ",
4106902, "cur", "Curitiba", "PR",
4314902, "poa", "Porto Alegre", "RS",
3106200, "bho", "Belo Horizonte", "MG",
5300108, "bsb", "Brasilia", "DF",
2927408, "sal", "Salvador", "BA",
1302603, "man", "Manaus", "AM",
2611606, "rec", "Recife", "PE",
5208707, "goi", "Goiania", "GO",
1501402, "bel", "Belem", "PA",
3518800, "gua", "Guarulhos", "SP",
3509502, "cam", "Campinas", "SP",
2111300, "slz", "Sao Luis", "MA",
3304904, "sgo", "Sao Goncalo", "RJ",
2704302, "mac", "Maceio", "AL",
3301702, "duq", "Duque de Caxias", "RJ",
5002704, "cgr", "Campo Grande", "MS",
2408102, "nat", "Natal", "RN"
) %>% setDT()
modo_munis <- tribble(
~abrev_muni, ~`2017`, ~`2018`, ~`2019`, ~`2020`,
"for", "todos", "todos", "todos", "todos",
"spo", "todos", "todos", "todos", "todos",
"rio", "ativo", "todos", "todos", "todos",
"cur", "todos", "todos", "todos", "todos",
"poa", "todos", "todos", "todos", "todos",
"bho", "todos", "todos", "todos", "todos",
"bsb", "ativo", "ativo", "ativo", "ativo",
"sal", "ativo", "ativo", "todos", "todos",
"man", "ativo", "ativo", "ativo", "ativo",
"rec", "ativo", "ativo", "todos", "todos",
"goi", "ativo", "ativo", "todos", "todos",
"bel", "ativo", "ativo", "ativo", "ativo",
"gua", "ativo", "ativo", "ativo", "ativo",
"cam", "todos", "todos", "todos", "todos",
"slz", "ativo", "ativo", "ativo", "ativo",
"sgo", "ativo", "ativo", "ativo", "ativo",
"mac", "ativo", "ativo", "ativo", "ativo",
"duq", "ativo", "ativo", "ativo", "ativo",
"cgr", "ativo", "ativo", "ativo", "ativo",
"nat", "ativo", "ativo", "ativo", "ativo"
) %>%
pivot_longer(cols = `2017`:`2020`, names_to = "ano", values_to = "modo") %>%
setDT()
metro_munis <- tribble(
~abrev_muni, ~ano, ~code_muni,
"for", 2017, 2304400,
"spo", 2017, 3550308,
"rio", 2017, 3304557,
"cur", 2017, 4106902,
"poa", 2017, 4314902,
"bho", 2017, 3106200,
"bsb", 2017, 5300108,
"sal", 2017, 2927408,
"man", 2017, 1302603,
"rec", 2017, 2611606,
"goi", 2017, 5208707,
"bel", 2017, 1501402,
"gua", 2017, 3518800,
"cam", 2017, 3509502,
"slz", 2017, 2111300,
"sgo", 2017, 3304904,
"mac", 2017, 2704302,
"duq", 2017, 3301702,
"cgr", 2017, 5002704,
"nat", 2017, 2408102,
"for", 2018, 2304400,
"spo", 2018, 3550308,
"rio", 2018, 3304557,
"cur", 2018, 4106902,
"poa", 2018, 4314902,
"bho", 2018, 3106200,
"bsb", 2018, 5300108,
"sal", 2018, 2927408,
"man", 2018, 1302603,
"rec", 2018, 2611606,
"goi", 2018, 5208707,
"bel", 2018, 1501402,
"gua", 2018, 3518800,
"cam", 2018, 3509502,
"slz", 2018, 2111300,
"sgo", 2018, 3304904,
"mac", 2018, 2704302,
"duq", 2018, 3301702,
"cgr", 2018, 5002704,
"nat", 2018, 2408102,
"for", 2019, 2304400,
"spo", 2019, 3550308,
"rio", 2019, 3304557,
"cur", 2019, 4106902,
"poa", 2019, 4314902,
"bho", 2019, 3106200,
"bsb", 2019, 5300108,
"sal", 2019, 2927408,
"man", 2019, 1302603,
"rec", 2019, 2611606,
"goi", 2019, 5208707,
"bel", 2019, 1501402,
"gua", 2019, 3518800,
"cam", 2019, 3509502,
"slz", 2019, 2111300,
"sgo", 2019, 3304904,
"mac", 2019, 2704302,
"duq", 2019, 3301702,
"cgr", 2019, 5002704,
"nat", 2019, 2408102,
"for", 2020, 2304400,
"spo", 2020, 3550308,
"rio", 2020, 3304557,
"cur", 2020, 4106902,
"poa", 2020, 4314902,
"bho", 2020, 3106200,
"bsb", 2020, 5300108,
"sal", 2020, 2927408,
"man", 2020, 1302603,
"rec", 2020, 2611606,
"goi", 2020, 5208707,
"bel", 2020, 1501402,
"gua", 2020, 3518800,
"cam", 2020, 3509502,
"slz", 2020, 2111300,
"sgo", 2020, 3304904,
"mac", 2020, 2704302,
"duq", 2020, 3301702,
"cgr", 2020, 5002704,
"nat", 2020, 2408102,
) %>% setDT()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment