Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erro nos comandos decorrente a atualização de dependencias #12

Open
pedrivom opened this issue Apr 3, 2024 · 1 comment
Open

Erro nos comandos decorrente a atualização de dependencias #12

pedrivom opened this issue Apr 3, 2024 · 1 comment
Assignees

Comments

@pedrivom
Copy link

pedrivom commented Apr 3, 2024

Os comandos do pacote estavam funcionando normalmente até eu atualizar o pacote "purrr", a partir desse momento começaram a apresentar o seguinte erro:

sp <- cepR::busca_cidades(estado = "SP", token = token)
Error in map_chr():
! In index: 1.
! With name: node.
Caused by error in pluck_raw():
! Can't pluck from a pointer at level 1.

rlang::last_trace()
<error/purrr_error_indexed>
Error in map_chr():
! In index: 1.
! With name: node.
Caused by error in pluck_raw():
! Can't pluck from a pointer at level 1.


Backtrace:

  1. ├─cepR::busca_cidades(estado = "SP", token = token)
  2. │ └─tibble::tibble(...)
  3. │ └─tibble:::tibble_quos(xs, .rows, .name_repair)
  4. │ └─rlang::eval_tidy(xs[[j]], mask)
  5. └─purrr::map_chr(...)
  6. └─purrr:::map_("character", .x, .f, ..., .progress = .progress)
  7. ├─purrr:::with_indexed_errors(...)
    
  8. │ └─base::withCallingHandlers(...)
    
  9. ├─purrr:::call_with_cleanup(...)
    
  10. └─cepR (local) .f(.x[[i]], ...)
    
  11.   └─purrr::pluck(.x, "nome", .default = NA_character_)
    
  12.     └─purrr:::pluck_raw(.x, list2(...), .default = .default)
    

Nos demais comandos não apresenta erro, apenas devolve a tabela com valores vazios:

cepR::busca_multi(lista_ceps = "81540000", token = token)

A tibble: 1 × 10

estado cidade bairro cep logradouro latitude longitude altitude ddd cod_IBGE

1 NA NA NA NA NA NA NA NA NA NA

@pedrivom
Copy link
Author

pedrivom commented Apr 3, 2024

aparentemente redefinindo a função parse_api(), substituindo dentro da subfunção pluck() o statement ".default = N" por ".default = NA", a busca de ceps volta a funcionar normalmente:

parse_api <- function(response) {
out <- tibble(
estado = pluck(response, "estado", .default = NA) %>%
pluck("sigla", .default = NA)%>%
as.character(),
cidade = pluck(response, "cidade", .default = NA) %>%
pluck("nome", .default = NA)%>%
as.character(),
bairro = pluck(response, "bairro", .default = NA)%>%
as.character(),
cep = pluck(response, "cep", .default = NA)%>%
as.character(),
logradouro = pluck(response, "logradouro", .default = NA)%>%
as.character(),
latitude = pluck(response, "latitude", .default = NA) %>%
as.numeric(),
longitude = pluck(response, "longitude", .default = NA) %>%
as.numeric(),
altitude = pluck(response, "altitude", .default = NA) %>%
as.numeric(),
ddd = pluck(response, "cidade", .default = NA) %>%
pluck("ddd", .default = NA) %>%
as.numeric(),
cod_IBGE = pluck(response, "cidade", .default = NA) %>%
pluck("ibge", .default = NA) %>%
as.character()
)
out
}

@RobertMyles RobertMyles self-assigned this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants