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

Problem retreiving data #35

Closed fdepaolis closed 3 years ago

fdepaolis commented 3 years ago

Hello, I tried the following code:

US.data.China <- ots_create_tidy_data(years = c(1980,1985,1990,1995,2000,2005,2010,2015,2018), reporters = 'usa', partners = 'chn')

US.data.Germany <- ots_create_tidy_data(years = c(1980,1985,1990,1995,2000,2005,2010,2015,2018), reporters = 'usa', partners = 'deu')

and the two tables are identical...am I doing something wrong here?

pachadotdev commented 3 years ago

Don @fdepaolis

Hi. First of all, happy holidays. Your code works here even when my connection is not the best, but you are calling the default table (yr) which means "exports from the USA to the world, aggregated" with your parameters.

Please notice that for the 80s you need to consider there were two ISO codes for Germany, but my comment is just to notice a distinction, not that I'm sidelined with one or other geopolitical arrangement totally outside of my area of knowledge.

You should run this

library(tradestatistics)

ots_country_code("Germany")

US.data.China <- ots_create_tidy_data(years = c(1980,1985,1990,1995,2000,2005,2010,2015,2018), reporters = 'usa', partners = 'chn', table = 'yrp')

US.data.Germany <- ots_create_tidy_data(years = c(1980,1985,1990,1995,2000,2005,2010,2015,2018), reporters = 'usa', partners = 'deu', table = 'yrp')

There is a very long (and boring) documentation that I wrote at docs.tradestatistics.io. There you'll find a lot of details, which are abridged at https://docs.ropensci.org/tradestatistics/articles/basic-usage.html#trade-data and specifies all of the table arguments and what those mean.

fdepaolis commented 3 years ago

...right...the default 'table' is yr, which is the reporter's totals (not by partner), that's why they are all the same value. I changed it to 'yrp' (which actually uses the 'partner' parameter) and everything is fine.

Thank you!!!!