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

Code for Scotland, England and N. Ireland #213

Closed
genann opened this issue Jul 21, 2017 · 27 comments
Closed

Code for Scotland, England and N. Ireland #213

genann opened this issue Jul 21, 2017 · 27 comments

Comments

@genann
Copy link

genann commented Jul 21, 2017

Hi I am writing to check if the new version has the same problem the old version had of missing the country codes for England, Scotland and Northern Ireland. I cannot seem to find it in the data(countries) file.

It can be done on the google page-->
For example:
https://trends.google.com/trends/explore?date=2009-01-01%202015-12-31&geo=GB-ENG&q=apple

Thanks again for your kind help!

@CharlotteWoolley
Copy link

CharlotteWoolley commented Nov 14, 2017

Hi,

I would like reiterate that I am also very interested in a solution to this problem that genann has brought up - In addition to Scotland, England and N. Ireland, there is also no category for Wales. It would be extremely useful if this could be resolved!

It seems that the appropriate country codes would be as follows (based on the URLS in the Google Trends website) but they can't be found in data(countries).

England = 'GB-ENG'
Scotland = 'GB-SCT'
Wales = 'GB-WLS'
Northern Ireland = 'GB-NIR'

Many thanks for your help!

@PMassicotte
Copy link
Owner

Do you have a downloadable data source we can use to populate our database of valid codes?

@genann
Copy link
Author

genann commented Nov 19, 2017 via email

@genann86
Copy link

England = 'GB-ENG'
Scotland = 'GB-SCT'
Wales = 'GB-WLS'
Northern Ireland = 'GB-NIR'

@PMassicotte
Copy link
Owner

We need a source to do it programatically (i.e. with code).

@CharlotteWoolley
Copy link

Hi PMassicotte,

What specific information do you need in the downloadable data source?
If I understand you correctly you need the geographical boundaries (e.g kml files) of the countries (England, Scotland, Wales and NI) boundaries.

Thank you!

@PMassicotte
Copy link
Owner

@CharlotteWoolley We need a file that ideally contains all codes. So we can parse it and add the information inside the package. Obviously, the source we are using at this time is missing some country codes.

@CharlotteWoolley
Copy link

@PMassicotte I think I have managed to find a suitable data source -

https://github.com/olahol/iso-3166-2.json/blob/master/data/eQuest.csv

This contains all the iso-3166-2 codes for each country, province and county/state.

It contains province codes for England. Scotland, Wales, NI, the isle of man and the Channel islands, so is very inclusive and seems to be accurate from some quick investigations.

If you need any more info, let me know!

Thanks!

@genann86
Copy link

genann86 commented Nov 23, 2017 via email

@PMassicotte
Copy link
Owner

Thank you @CharlotteWoolley I will try to do it this week.

@PMassicotte
Copy link
Owner

I have found an update to the list we are using
https://www.unece.org/cefact/codesfortrade/codes_index.html

However, the missing codes you are looking for are not present. In our list, we have 92821 entries compared to only 4k in your list.

@CharlotteWoolley
Copy link

Hi @PMassicotte,

Sorry for my delay replying to this - I have been working on joining the 2 data sources together and removing any formatting problems. I think I now have a data source which you will be able to use -

https://github.com/CharlotteWoolley/Comprehensive_ISO_Location_Codes/blob/master/ISO_codes.csv

This contains more codes - 122635 and joins the data from the source that you normally use to the codes that I would like to add.

E.g. The data source now has all the states of the US included and all of the principalities of the UK that myself and @genann86 would like.

Please would you be able to have a look and see if this is a more suitable data source?

Thanks!

@PMassicotte
Copy link
Owner

@CharlotteWoolley Is you list also contains our codes? Can you compare it and see if we have codes you do not have?

@genann86
Copy link

genann86 commented Nov 29, 2017 via email

@CharlotteWoolley
Copy link

@PMassicotte yes it does - It joins all of your codes together with my codes.

Using the following code returns 89953 (the same length as the gtrendsR countries dataset), so all of your codes are definitely contained -

library(gtrendsR)
data(countries)
sum(countries$country_code %in% ISO_codes$country_code)

The only differences are the number of codes and the names column of the countries - I capitalised all of the names and removed full stops to make it easier to remove duplicates after joining the data together.

If you would like to explicitly see how I have joined them together my code is here:

https://github.com/CharlotteWoolley/Comprehensive_ISO_Location_Codes/blob/master/get_ISO_codes.R

Thanks!

@PMassicotte
Copy link
Owner

@CharlotteWoolley Good. I will try to update it today.

@PMassicotte
Copy link
Owner

It should be working now.

                                      
library(gtrendsR)                     
                                      
plot(gtrends("pizza", geo = "GB-ENG"))

@genann86
Copy link

genann86 commented Dec 19, 2017 via email

@CharlotteWoolley
Copy link

Thank you! 👍

@Dea89
Copy link

Dea89 commented Jan 4, 2018

Hi! Unfortunately for me it still doesn't work. I still receive the same error message for plot(gtrends("pizza", geo = "GB-ENG")): "Error: Country code not valid. Please use 'data(countries)' to retrieve valid codes."...
I have reinstalled the package and everything, but still no result. Thanks in advance!

@CharlotteWoolley
Copy link

CharlotteWoolley commented Jan 5, 2018

Yes @PMassicotte, I have been away for 2 weeks so haven't been able to test this but I am also having the same problem. The country codes don't seem to have changed at all, despite having tried updating the package, re-installing the package etc etc.

Thanks,

Charlotte

@PMassicotte
Copy link
Owner

Have you installed the dev version?

@Dea89
Copy link

Dea89 commented Jan 5, 2018

I have tried several ways to do that, and at first I would still get the same error, but after the third attempt gtrends stopped working for me completely. Now I get this message: "Error in hl %in% language_codes$code :
lazy-load database 'C:/Users/Katyusha/Documents/R/win-library/3.4/gtrendsR/R/sysdata.rdb' is corrupt
In addition: Warning messages:
1: In hl %in% language_codes$code :
restarting interrupted promise evaluation
2: In hl %in% language_codes$code : internal error -2 in R_decompress1".

@PMassicotte
Copy link
Owner

Try to re-install the dev version. Package installation can be corrupted times to times.

@CharlotteWoolley
Copy link

Thanks yes, it is now working!

@Dea89
Copy link

Dea89 commented Jan 11, 2018

British codes are working now, but the american ones stopped working :( gtrends("pizza", geo = "US-NY")

@PMassicotte
Copy link
Owner

Should be working now. We have also added a new parameter to include low search volume.

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

No branches or pull requests

5 participants