3

I would like to use the gtrends command to search keywords. The basic syntax is simple as in the following:

special.kw<-gtrends("special")

However, I would like to search for more than just "special". I would also like to include in the keyword search hits measure any searches for "speciality", "specialization", "specially". I could do the following:

special.kw<-gtrends(c("special", "speciality", "specially", "specialization"))

But this provides with 4 different searches with a different measure for each. I would like to combine the search hits for each of these using a regular expression (or some sort of wild card expressions). Also note, google trends hit measures are based on a normalized scale of 0-100, so I can't just separately search for these terms from above and add the values together -that would distort the measure. I tried messing around with stringr and grep but nothing really panned out. Any help is much appreciated. Here is a working example from scratch:

library(gtrendsR)

ch <- gconnect("xxxx@xxx.com", "xxxxxx")
special.kw<-gtrends("special")
Cyrus Mohammadian
  • 4,982
  • 6
  • 33
  • 62
  • 1
    the doc doesn't really imply that it supports regular expressions or globbing so you might be out of luck – rawr May 02 '16 at 19:42
  • Google Trends search is already fuzzy, results for ' "data analyst" ' (exact match) and 'data analyst' (fuzzy match) differ. Maybe that's already ok for you. I don't think Google offers wildcards of regex, too, have you browsed the API documentation? – lukeA May 02 '16 at 20:13
  • 1
    I have checked the API documentation and it surprisingly didn't have anything on the topic. Also checked the gtrendsR documentation and didn't find anything on the topic. However, I am able to search at least multiple search terms together. ``gtrends("special + speciality + specially +specialization", start_date="2004-01-01")`` – Cyrus Mohammadian May 03 '16 at 10:37

0 Answers0