if (FALSE) {
# set project billing id
basedosdados::set_billing_id("avalidprojectbillingid")
# connects to the remote table I want
base_sim <- bdplyr("br_ms_sim.municipio_causa_idade")
# connects to another remote table
municipios <- bdplyr("br_bd_diretorios_brasil.municipio")
# explore data
base_sim %>%
dplyr::glimpse()
# use normal `{dplyr}` operations
municipios %>%
head()
# filter
base_sim_acre <- base_sim %>%
dplyr::mutate(ano = as.numeric(ano)) %>%
dplyr::filter(sigla_uf == "AC", ano >= 2018)
municipios_acre <- municipios %>%
dplyr::filter(sigla_uf == "AC") %>%
dplyr::select(id_municipio, municipio, regiao)
# join
base_junta <- base_sim_acre %>%
dplyr::left_join(municipios_acre,
by = "id_municipio")
# tests whether the result is satisfactory
base_junta
# collect the result
base_final <- base_junta %>%
basedosdados::bd_collect()
# alternatively, write in disk the result
base_final %>%
basedosdados::bd_write_rds(path = "data-raw/data.rds")
}
Run the code above in your browser using DataLab