gtrendsR
gtrendsR copied to clipboard
Or query has less results than individual terms
I'm having trouble understanding results from an or-query. When I do the following or-query for searches for dog or cat by DMA, I get results for about 73 DMAs, with 140 or so "NA" results:
res <-gtrends('dog+cat', geo= c("US"), time ="2017-01-01 2018-01-01") res$interest_by_dma
Seemingly, most DMAs don't search cat or dog very much. However, if I run the following commands for just dog, I get results for every single DMA:
res <-gtrends('dog', geo= c("US"), time ="2017-01-01 2018-01-01") res$interest_by_dma
How is it possible that search volume for Cat or Dog is less than that for just Dog? What's wrong here? Thanks so much.
Me as well, but this problem exists on the google trends website as well.
Try to compare what Google returns and what we return. If they are the same, then we can't do anything about it.
Hi sorry when I check now it works. for example on the website i get 78 cities for gtrends(c("apple + pear"),geo=("GB"), time=("2016-01-01 2016-12-31")) $interest_by_city
but in gtrendsR i get only London. It does indeed seem to be reading it as an 'and' as opposed to an 'OR'. # # #277
Sorry, I am now following the same @genann86 project, and I am stuck in the same problem: it reads the plus as an AND and not as an OR. Does anyone know if it there is a way to fix this?
I have the same problem. It seems that + is indeed taken as AND, whereas it is used for OR on Google Trends. Here is the comparison:
res <- gtrends(keyword = c('adidas+nike', 'adidas', 'nike', 'adidas nike'))
This produces the same results for the first and the last keywords, whereas they are vastly different on Google Trends:

Anyone with some bright ideas?
What would be the "AND" then?
Here are the search tips from Google that include various operators:
https://support.google.com/trends/answer/4359582?hl=en
For adidas nike:
https://trends.google.fr/trends/api/widgetdata/multiline/csv?req=%7B%22time%22%3A%222017-10-09%202018-10-09%22%2C%22resolution%22%3A%22WEEK%22%2C%22locale%22%3A%22fr%22%2C%22comparisonItem%22%3A%5B%7B%22geo%22%3A%7B%22country%22%3A%22FR%22%7D%2C%22complexKeywordsRestriction%22%3A%7B%22keyword%22%3A%5B%7B%22type%22%3A%22BROAD%22%2C%22value%22%3A%22adidas%20nike%22%7D%5D%7D%7D%5D%2C%22requestOptions%22%3A%7B%22property%22%3A%22%22%2C%22backend%22%3A%22IZG%22%2C%22category%22%3A0%7D%7D&token=APP6_UEAAAAAW73qeTVfoh22C1H8OdqRY0ZrVheexeI6&tz=240
"https://trends.google.fr/trends/api/widgetdata/multiline/csv?req={\"time\":\"2017-10-09 2018-10-09\",\"resolution\":\"WEEK\",\"locale\":\"fr\",\"comparisonItem\":[{\"geo\":{\"country\":\"FR\"},\"complexKeywordsRestriction\":{\"keyword\":[{\"type\":\"BROAD\",\"value\":\"adidas nike\"}]}}],\"requestOptions\":{\"property\":\"\",\"backend\":\"IZG\",\"category\":0}}&token=APP6_UEAAAAAW73qeTVfoh22C1H8OdqRY0ZrVheexeI6&tz=240"
For adidas+nike:
https://trends.google.fr/trends/api/widgetdata/multiline/csv?req=%7B%22time%22%3A%222017-10-09%202018-10-09%22%2C%22resolution%22%3A%22WEEK%22%2C%22locale%22%3A%22fr%22%2C%22comparisonItem%22%3A%5B%7B%22geo%22%3A%7B%22country%22%3A%22FR%22%7D%2C%22complexKeywordsRestriction%22%3A%7B%22keyword%22%3A%5B%7B%22type%22%3A%22BROAD%22%2C%22value%22%3A%22adidas%22%7D%2C%7B%22type%22%3A%22BROAD%22%2C%22value%22%3A%22nike%22%7D%5D%2C%22operator%22%3A%22OR%22%7D%7D%5D%2C%22requestOptions%22%3A%7B%22property%22%3A%22%22%2C%22backend%22%3A%22IZG%22%2C%22category%22%3A0%7D%7D&token=APP6_UEAAAAAW73qU3c1t3b3IFZbUaIT2j4mBKJB2BCD&tz=240
"https://trends.google.fr/trends/api/widgetdata/multiline/csv?req={\"time\":\"2017-10-09 2018-10-09\",\"resolution\":\"WEEK\",\"locale\":\"fr\",\"comparisonItem\":[{\"geo\":{\"country\":\"FR\"},\"complexKeywordsRestriction\":{\"keyword\":[{\"type\":\"BROAD\",\"value\":\"adidas\"},{\"type\":\"BROAD\",\"value\":\"nike\"}],\"operator\":\"OR\"}}],\"requestOptions\":{\"property\":\"\",\"backend\":\"IZG\",\"category\":0}}&token=APP6_UEAAAAAW73qU3c1t3b3IFZbUaIT2j4mBKJB2BCD&tz=240"
Looking at the decoded URL, the interesting part is:
{\"keyword\":[{\"type\":\"BROAD\",\"value\":\"adidas\"},{\"type\":\"BROAD\",\"value\":\"nike\"}],\"operator\":\"OR\"}
One would need to split the query string into subsets. Any help welcome :)
Also the "quoted" case of "adidas nike":
https://trends.google.fr/trends/api/widgetdata/multiline/csv?req=%7B%22time%22%3A%222017-10-09%202018-10-09%22%2C%22resolution%22%3A%22WEEK%22%2C%22locale%22%3A%22fr%22%2C%22comparisonItem%22%3A%5B%7B%22geo%22%3A%7B%22country%22%3A%22FR%22%7D%2C%22complexKeywordsRestriction%22%3A%7B%22keyword%22%3A%5B%7B%22type%22%3A%22PHRASE%22%2C%22value%22%3A%22adidas%20nike%22%7D%5D%7D%7D%5D%2C%22requestOptions%22%3A%7B%22property%22%3A%22%22%2C%22backend%22%3A%22IZG%22%2C%22category%22%3A0%7D%7D&token=APP6_UEAAAAAW73sT2fGMYWP73FEj12B2R9DyIRc0y5l&tz=240
"https://trends.google.fr/trends/api/widgetdata/multiline/csv?req={\"time\":\"2017-10-09 2018-10-09\",\"resolution\":\"WEEK\",\"locale\":\"fr\",\"comparisonItem\":[{\"geo\":{\"country\":\"FR\"},\"complexKeywordsRestriction\":{\"keyword\":[{\"type\":\"PHRASE\",\"value\":\"adidas nike\"}]}}],\"requestOptions\":{\"property\":\"\",\"backend\":\"IZG\",\"category\":0}}&token=APP6_UEAAAAAW73sT2fGMYWP73FEj12B2R9DyIRc0y5l&tz=240"
But it looks like we can do it already:
library(gtrendsR)
res <- gtrends(keyword = c("adidas nike", "\"adidas nike\""))
plot(res)

Created on 2018-10-09 by the reprex package (v0.2.1)
hi, sorry to post again on that issue but I didn't find if the query1 + query2 is now possible with the package? cheers
Not right now bt working on it.
thank you very much for working on it and the prompt reply
Thank you for providing this great package! I was wandering if there are updates on the "or query".
'res <- gtrends(keyword = c("adidas nike", ""adidas nike"")) ' does not work for me, when i use other serach terms, e.g. 'res <- gtrends(keyword = c("vienna feldkirch", ""vienna feldkirch""))'.
best
Use res <- gtrends(keyword = c("adidas nike", "\"adidas nike\"")) as mentioned above. It should work.
Concerning the OR operator + should be supported now since #311.
E.g. plot(gtrends(keyword=c("opel + astra", "opel", "astra"),time='2004-01-01 2018-05-31', gprop ='web', geo ='' ,hl='en-US',cat = "0"))
Thanks for the fast answer. I tried it today for the tennis example. Unfortunately it doesnt work. Also not when installing the developer version.
I used: plot(gtrends(c("tennis","tennis shoes","tennis+shoes","tennis -shoes"),time = "all"))
Do I miss something?
Cheers

Try it again. The dev version, did not include my PR yet. Sorry for that. My result for the example is the following.

Hey! thanks for the efforts.
For now I am running into issues loading the developer version:
Error in i.p(...) : (converted from warning) installation of package ‘FILE_PATH' had non-zero exit status in R’ had non-zero exit status
Thanks a lot.
Most likely not related to the package.