rfsaldanha / microdatasus

Download de dados do DataSUS e pré-processamento no R.
https://rfsaldanha.github.io/microdatasus/
Other
230 stars 57 forks source link

Problem with different column type in `process_sim` #49

Closed dcardosos closed 2 years ago

dcardosos commented 2 years ago

Hi!

The function process_sim return an error when process "OCUP" column. The error is:

Error in dplyr::left_join(): ! Can't join on x$OCUP x y$OCUP because of incompatible types. ℹ x$OCUP is of type >. ℹ y$OCUP is of type >. Backtrace:

  1. microdatasus::process_sim(dados)
  2. dplyr:::left_join.data.frame(data, tabOcupacao, by = "OCUP")

I identify the problem here:

https://github.com/rfsaldanha/microdatasus/blob/8ee453b630e9fc4fb4ec70f8533746bee51f7487/R/process_sim.R#L191-L204

When the code do colnames(tabOcupacao)[1] <- "OCUP" colnames(tabCBO)[1] <- "OCUP"

The type of these columns is integer, not character, and this causes the above error. I propose a Pull request to change this.

Thanks

rfsaldanha commented 2 years ago

That's great, thanks you!