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

Does the package work for other classifications? #16

Closed
raphael-gouvea opened this issue Apr 17, 2018 · 6 comments
Closed

Does the package work for other classifications? #16

raphael-gouvea opened this issue Apr 17, 2018 · 6 comments

Comments

@raphael-gouvea
Copy link

@raphael-gouvea raphael-gouvea commented Apr 17, 2018

@ChrisMuir , does the package work with other classifications? I tried using SITCrev4 and it failed. I could not find an option on ct_search related to the database type.

library(comtradr)
# Update and select SITCrev4
ct_update_databases(commodity_type = "SITCrev4")
#> Updates found. The following datasets have been downloaded: commodities DB
ct_commodity_db_type()
#> [1] "SITCrev4"
ex_1 <- ct_search(reporters = "China",
                  partners = c("Rep. of Korea", "USA", "Mexico"),
                  trade_direction = "exports")
#> Error: API request failed, with status code [200]
#> Fail Reason: SITCrev4 is an invalid trade classification
@ChrisMuir
Copy link
Member

@ChrisMuir ChrisMuir commented Apr 22, 2018

Hi Raphael,

Thank you for reporting this! Yes the intention is for the package to work with any of the commodity-type classifications that the UN Comtrade supports.....the error is being caused by a bug in how the pkg indicates commodity classification (it's passing the string SITCrev4, while the API is looking for S4).

I will try to get this fixed this weekend. Thanks again!

ChrisMuir added a commit that referenced this issue Apr 22, 2018
@ChrisMuir
Copy link
Member

@ChrisMuir ChrisMuir commented Apr 22, 2018

Just pushed a fix for this, @raphael-gouvea do you mind pulling the dev version of the pkg from GitHub and trying again?

@raphael-gouvea
Copy link
Author

@raphael-gouvea raphael-gouvea commented Apr 22, 2018

Now I get a different error message.

library(comtradr)

# Update and select SITCrev4
ct_update_databases(commodity_type = "SITCrev4")
#> Updates found. The following datasets have been downloaded: commodities DB
#> Updates found. The following datasets have been downloaded: commodities DB

ct_commodity_db_type()
#> [1] "SITCrev4"

ex_1 <- ct_search(reporters = "China",
                  partners = c("Rep. of Korea", "USA", "Mexico"),
                  trade_direction = "exports")
#> Error in sprintf("Comtrade API request failed, with status code [%s]\n%s", : too few arguments

sessionInfo()
#> R version 3.4.4 (2018-03-15)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 16.04.4 LTS
#> 
#> Matrix products: default
#> BLAS: /usr/lib/libblas/libblas.so.3.6.0
#> LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] comtradr_0.1.0.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] Rcpp_0.12.16    bookdown_0.7    digest_0.6.15   rprojroot_1.3-2
#>  [5] R6_2.2.2        jsonlite_1.5    backports_1.1.2 magrittr_1.5   
#>  [9] evaluate_0.10.1 httr_1.3.1      rlang_0.2.0     stringi_1.1.7  
#> [13] curl_3.2        rmarkdown_1.9   tools_3.4.4     stringr_1.3.0  
#> [17] purrr_0.2.4     xfun_0.1        yaml_2.1.18     compiler_3.4.4 
#> [21] htmltools_0.3.6 knitr_1.20
ChrisMuir added a commit that referenced this issue Apr 22, 2018
@ChrisMuir
Copy link
Member

@ChrisMuir ChrisMuir commented Apr 22, 2018

Arg, that error was related to a bug in one of the calls to sprintf(). I just patched that bug, can you give it another shot?

What's alarming though is that the sprintf() error indicates your API request returned a status code that was NOT 200.

@raphael-gouvea
Copy link
Author

@raphael-gouvea raphael-gouvea commented May 1, 2018

Thanks @ChrisMuir, it worked. Sorry for the delay.

@ChrisMuir
Copy link
Member

@ChrisMuir ChrisMuir commented May 1, 2018

Cool, no worries. Thanks again for bringing this to my attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.