ropensci / tradestatistics

R package to access Open Trade Statistics API
https://docs.ropensci.org/tradestatistics
Apache License 2.0
76 stars 14 forks source link

Getting identical export/import values for all countries #37

Closed hktseng closed 3 years ago

hktseng commented 3 years ago

Hi,

I notice that ots_create_tidy_data() returns identical export/import values for country pairs originating from the same "reporter," for example:

d <- ots_create_tidy_data(years = 2000, reporters = "usa", partners = c("afg", "can"), products=c("0101", "0705"), table="yrc", max_attempts=5)

which returns

d[, c(2, 10, 13:16)] reporter_iso product_code export_value_usd export_rca import_value_usd import_rca 1: usa 0101 672770373 2.1196 485633089 1.1655 2: usa 0101 672770373 2.1196 485633089 1.1655 3: usa 0705 223787742 1.4500 43872463 0.2130 4: usa 0705 223787742 1.4500 43872463 0.2130

not sure what the reported values are supposed to be because they aren't aggregated values either.

Suppose I want to retrieve the export/import values for reporter-partner country pair i-j across k product codes, what exactly should I specify the ots_create_tidy_data() argument? Say, for example, reporter list c("usa", "can", "chl", "chn", "arg"), partners list c("usa", "can", "chl", "chn", "arg"), and product code c("0101", "0705"), such as

d <- ots_create_tidy_data(years = 2000, reporters = c("usa", "can", "chl", "chn", "arg"), partners = c("usa", "can", "chl", "chn", "arg"), products=c("0101", "0705"), table="yrc", max_attempts=5)

Also, when setting the "table" argument to "yrc", the output will not report partners' iso country code (as compared to when table is set to "yrp", yet this method will not report produce code). It will be a bit difficult to distinguish a reporter's export/import values of a particular product category to a particular "partner" from the output if I include a long list of partners in the function. I am wondering if there's any way to get around this?

By all account, awesome and handy function!

pachadotdev commented 3 years ago

hi I think I replied this question by email, what I'd do it to combine both purrr and this package, to:

  1. avoid transferring large tables
  2. copy the data by parts

for the next version I'll work on many server side improvements

hktseng commented 3 years ago

Hi,

I think you did. The error is caused by my erroneous "table" argument. After I set table="yrpc", it works fine. As always, many thanks to your help on this!

Best regards, H K Tseng

Pachá @.***> 於 2021年7月6日 週二 上午10:05寫道:

hi I think I replied this question by email, what I'd do it to combine both purrr and this package, to:

  1. avoid transferring large tables
  2. copy the data by parts

for the next version I'll work on many server side improvements

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/ropensci/tradestatistics/issues/37#issuecomment-874407294, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOPBH7VJS6UVQKSGVNWBEGDTWJQG3ANCNFSM42TGNFLQ .