How to merge and normalize Google Trends datasets with R?

323 Views Asked by At

My goal is to compare the interest over time regarding some animal groups, and, for this, I will utilize gtrendsR package. As I intend to include more than five groups in my research (i.e., more than five keywords in Google Trends), thus exceeding the search queries limit allowed by Google Trends, I must to perform different sets of searches, each containing five keywords, one of which needs the one with the peak value. These are my R commands, regarding the data collection (Lion got the highest peak value):

> library(gtrendsR)

> # Setting the search terms:

> keywords_1 <- c("Lion", "Butterfly", "Cockroach", "Parrot", "Ostrich")

> keywords_2 <- c("Lion", "Platypus", "Alligator", "Hyena", "Horse")

> country <- c('BR') #setting the geographic area (Brazil).

> time <- ("2011-01-01 2021-12-31") #setting the period.

> channel <- 'web' #setting the channels.
    
> Running the queries:

> data1 <- gtrends(keywords_1, gprop = channel, geo = country, time = time, category = 0)

> data2 <- gtrends(keywords_2, gprop = channel, geo = country, time = time, category = 0)

At this point, my question is how can I merge data1 and data2 into a single dataset. I know that all data must be normalized to the peak value, which is Lion; but how can I perform this normalization in R?

0

There are 0 best solutions below