geobr icon indicating copy to clipboard operation
geobr copied to clipboard

refactor function cep_to_state

Open aspeddro opened this issue 4 years ago • 1 comments

This PR refactor cep_to_state function.

  • Remove nesteds ifelse, uses a structure that is easier to maintain
  • Remove unnecessary vectorization (ifelse and &)
  • Stricter verification, now cep_to_state("7900000000000000") raise a error. Currently return "MS"

aspeddro avatar Nov 17 '21 20:11 aspeddro

Hi @aspeddro . Thank you for your contribution and pleace accept my apologies for taking so much time to get back to you. The code of the function looks much nicer now. However, the new function does not pass the tests in test-cep_to_state.R.

The function should be able to throw an informative error message in these situations below:

cep_to_state(cep = 'aaaa') 
cep_to_state() 

rafapereirabr avatar Aug 02 '22 12:08 rafapereirabr

I've added a few checks that were missing. Thanks!

rafapereirabr avatar Jul 08 '23 18:07 rafapereirabr