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

Namibia's iso2c code is treated as NA rather than "NA" #26

Open
cportner opened this issue Sep 9, 2020 · 1 comment
Open

Namibia's iso2c code is treated as NA rather than "NA" #26

cportner opened this issue Sep 9, 2020 · 1 comment

Comments

@cportner
Copy link

cportner commented Sep 9, 2020

Namibia's iso2c code is "NA", but wb_data returns missing instead of the string. Hence, you cannot merge on it.

wb_data("countries_only",
        indicator = c("SP.POP.TOTL", "SP.URB.TOTL"),
        mrv = 1,
        gapfill = TRUE, return_wide = TRUE) %>%
  left_join(wb_cachelist$countries[, c('iso3c','region')], by = c('iso3c')) %>% 
  filter(iso3c == "NAM")

wb_data("countries_only",
        indicator = c("SP.POP.TOTL", "SP.URB.TOTL"),
        mrv = 1,
        gapfill = TRUE, return_wide = TRUE) %>%
  left_join(wb_cachelist$countries[, c('iso2c','region')], by = c('iso2c')) %>% 
  filter(iso3c == "NAM")
@jpiburn
Copy link
Contributor

jpiburn commented Feb 28, 2021

Hi... my apologies for not replying sooner than this... The end of Sept was a very busy time for me, so I must have missed this...

Namibia's iso2c code has been a source of many problems... I just tried the examples you provided and it seemed to have worked as expected. Can you confirm that you are still seeing this issue? If so would you mind providing the output of sessionInfo()

Thanks!

library(wbstats)
library(tidyverse)
#> Warning: package 'tidyverse' was built under R version 3.6.3
#> Warning: package 'tibble' was built under R version 3.6.3
#> Warning: package 'tidyr' was built under R version 3.6.3
#> Warning: package 'purrr' was built under R version 3.6.1
#> Warning: package 'dplyr' was built under R version 3.6.3
#> Warning: package 'forcats' was built under R version 3.6.3

wb_data("countries_only",
        indicator = c("SP.POP.TOTL", "SP.URB.TOTL"),
        mrv = 1,
        gapfill = TRUE, return_wide = TRUE) %>%
  left_join(wb_cachelist$countries[, c('iso3c','region')], by = c('iso3c')) %>% 
  filter(iso3c == "NAM")
#> # A tibble: 1 x 7
#>   iso2c iso3c country  date SP.POP.TOTL SP.URB.TOTL region            
#>   <chr> <chr> <chr>   <dbl>       <dbl>       <dbl> <chr>             
#> 1 NA    NAM   Namibia  2020     2494530     1273258 Sub-Saharan Africa

wb_data("countries_only",
        indicator = c("SP.POP.TOTL", "SP.URB.TOTL"),
        mrv = 1,
        gapfill = TRUE, return_wide = TRUE) %>%
  left_join(wb_cachelist$countries[, c('iso2c','region')], by = c('iso2c')) %>% 
  filter(iso3c == "NAM")
#> # A tibble: 1 x 7
#>   iso2c iso3c country  date SP.POP.TOTL SP.URB.TOTL region            
#>   <chr> <chr> <chr>   <dbl>       <dbl>       <dbl> <chr>             
#> 1 NA    NAM   Namibia  2020     2494530     1273258 Sub-Saharan Africa

Created on 2021-02-27 by the reprex package (v0.3.0)

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