-
Notifications
You must be signed in to change notification settings - Fork 112
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
Missing country: "NA" #202
Comments
I will try to explore the problem this week. |
I ran into the same problem as @ucb and decided to have a look at the issue. I managed to solve it eventually, with a cheap workaround... The first step is replacing the Namibia country code in data(countries) from logical to character. This needs to be changed in the sysdata as well, otherwise gtrends won't recognize it and will return the same error code. A second step is necessary in the get_widget function. The issue is that Namibia's country code gets converted to logical NA from JSON, thus causing problems with the functions that depend on it. However, by strategically replacing the content of widget in the columns referring to the country code, I was able to get the correct structure required to run the remaining functions and it seems to return the same data as the website. If people are looking for a simple workaround for this issue, you can add the following lines at the end of the get_widget function:
There might be a more elegant solution, but I wasn't able to come up with any... Hope this helps @PMassicotte and thanks for the great work on the package! |
Another update, as I just noticed that Kosovo (country code "XK") is also missing from the countries list. An entry for Kosovo is present, but it has the Macedonia (FYROM) code "MK". Either changing this or adding a new line for Kosovo specifically, in both countries.rda and sysdata.rda will solve the issue. |
The best way to do it is programmatically. Should check if the list we are using has been updated. |
Sure. I wasn't certain where the data came from and wanted to find a quick fix, so that did the trick. However, I checked the link you shared and there has been no change for Kosovo. Either way, thanks for the great work! |
More than happy to include an updated version of data if you can find a reliable source! |
The issue seems to be that ISO still hasn't officially assigned a code to Kosovo. The issue is more or less explained here: https://geonames.wordpress.com/2010/03/08/xk-country-code-for-kosovo/ XK was assigned as a temporary code to Kosovo under UN Security Council resolution 1244/99 and Google seems to go with it, but it won't be in any "official" ISO country list given it has not officially recognized by ISO as of yet. The code can be found in some country lists such as the WorldBank (see for example wb_api2c in package countrycode), but not in any ISO list that I could find... |
Just for the sake of completeness: The "NA" == NA issue seems to be caused by a corner case parsing problem in {jsonlite}. My patch #353 circumvents this problem and I also filed an PR with the {jsonlite} coordinator: jeroen/jsonlite#318 |
It may sound like a pun, but "NA" is Namibia and works fine with Google website.
Error: Country code not valid. Please use 'data(countries)' to retreive valid codes
The text was updated successfully, but these errors were encountered: