Comments (7)
FYI @jugdemon , API is back up and running.
from comtradr.
Good to know that it is not just me. In the meantime I used the manual interface of the worldbank to comtrade to download excel files with the necessary information. Apparently, they still have access (or more likely they run a replica). It looks like a cool package and I will use it the next time I have to access comtrade.
from comtradr.
A quick question, could it be, that the upgrade has rendered comtradr not working? When I make any queries, they always return empty (also on the comtrade.un.org).
from comtradr.
Ah, yeah that's interesting, I had no idea the API was down, thank you for bringing it to my attention. I'm not sure what's causing it. It's odd that their online data interface doesn't indicate the service being down or anything like that.
I'll keep my eyes on this, if the outage persist for more than today I will send them a bug report email asking what's going on.
Thanks!
from comtradr.
Hello Chris Muir,
I did not find a specific topic for my question. I would like to know if there is any command in comtradr to use country codes instead of the country names in the ct_search command.
Thank you for understanding
from comtradr.
Hello @wallacemp , nope the query function ct_search()
does not support passing country codes as input. You can, however, create your own wrapper function, like I've demoed below, that will allow you to pass in country codes, and will convert the inputs to their character country names prior to calling ct_search()
. Be aware, this is a super hacky fix, it uses comtradr:::get_country_db()
, which is an undocumented non-exported function. Also, there are no checks to ensure the input ints are valid country codes, although you could easily add those checks to the wrapper function below. Hope this is helpful!
ct_search2 <- function(reporters, partners, ...) {
if (!is.character(reporters)) {
reporters <- as.character(reporters)
}
if (!is.character(partners)) {
partners <- as.character(partners)
}
country_df <- comtradr:::get_country_db()
reporters <- vapply(reporters, function(x) {
country_df[country_df$code == x &
country_df$reporter == TRUE, ]$country_name
}, character(1), USE.NAMES = FALSE)
partners <- vapply(partners, function(x) {
country_df[country_df$code == x &
country_df$partner == TRUE, ]$country_name
}, character(1), USE.NAMES = FALSE)
return(comtradr::ct_search(reporters, partners, ...))
}
df <- ct_search2(reporters = 156,
partners = c(276, 288, 392, 484),
trade_direction = "imports",
start_date = 2010,
end_date = 2014)
dim(df)
#> [1] 20 35
The example above is equivalent to doing:
df <- ct_search(reporters = "China",
partners = c("Germany", "Ghana", "Japan", "Mexico"),
trade_direction = "imports",
start_date = 2010,
end_date = 2014)
from comtradr.
Closing this issue, as changes will be adressed in planned relaunch. #45
from comtradr.
Related Issues (20)
- ct_get_remaining_hourly_queries() does not get updated after validating token HOT 1
- Error after registration of API token HOT 29
- RStudio - error Error in curl::handle_setopt(handle, .list = req$options) : Unknown options: curlopt_ssl_verifypeer, set.ssl.primary.verifypeer HOT 1
- Error Message Maximum resultset is: 10000 HOT 1
- API will be decommissioned by 2023 HOT 13
- New Maintainer Needed HOT 20
- Planned re-launch of comtradr HOT 6
- Getting data HOT 1
- Add a "depreciated" error to legacy functions HOT 2
- Verify possible values for the frequency arg HOT 1
- Extend possible values for the commodity_classification arg HOT 3
- Provide an argument that allows users to pull all countries and country groupings HOT 1
- updating reference tables HOT 4
- reduce dependencies / magrittr pipe? HOT 1
- add validation for new arguments partner2, mode_of_transportation and customs_code HOT 1
- goodpractice HOT 1
- rebuild the vignettes
- document functions
- write test suite HOT 2
- reactivate pretty_cols HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from comtradr.