add_control_keyword {globaltrends}R Documentation

Add batches of control or object keywords

Description

The function adds one or more batches of keywords with a time period for downloads to the database. The batches serve as input for all download and computation functions.

Usage

add_control_keyword(keyword, time = "2010-01-01 2020-12-31")

add_object_keyword(keyword, time = "2010-01-01 2020-12-31")

Arguments

keyword

Keywords that should be added as batch. Vector of type character or a list of character vectors. The function also allows the usage of codes for search topics instead of search terms.

time

Time frame for which the batch data should be downloaded. Object of type character that takes the from "YYYY-MM-DD YYYY-MM-DD". Defaults to "2010-01-01 2020-12-31".

Details

Since Google Trends allows a maximum of five keywords for each query, batches of control keywords can consist of up to five keywords. Since one control keyword is added to batches of object keywords for mapping, object batch length is limited to four keywords. When a character vector contains more than four (five) keywords, the vector is split into four-keyword (five-keyword) batches. A list must contain character vectors of length four (five) or less. Each batch of keywords is combined with a time period for which data will be downloaded. To change the time period for an existing batch, all downloads and computations must be rerun.

Value

Message that the batch has been created successfully. Batch data is written to tables batch_keywords and batch_time. Numeric vector containing the newly added batch numbers are returned.

Warning

If you use search topics for object keywords, make sure to use search topics for control keywords and vice versa. See Google's FAQ for additional information on search topics.

Note

To avoid trailing spaces stringr::str_squish is automatically applied to all keywords.

See Also

Examples

## Not run: 
add_control_keyword(
  keyword = c("gmail", "maps", "translate", "wikipedia", "youtube"),
  time = "2016-01-01 2019-12-31"
)
add_object_keyword(
  keyword = c("apple", "facebook", "google", "microsoft"),
  time = "2016-01-01 2019-12-31"
)

add_control_keyword(
  keyword = c("gmail", "maps", "news", "translate", "weather", "wikipedia", "youtube"),
  time = "2016-01-01 2019-12-31"
)
add_control_keyword(
  keyword = c("amazon", "apple", "facebook", "google", "microsoft", "netflix", "twitter"),
  time = "2016-01-01 2019-12-31"
)

add_control_keyword(
  keyword = list(
    c("gmail", "maps", "news"),
    c("translate", "weather", "wikipedia", "youtube")
  ),
  time = "2016-01-01 2019-12-31"
)
add_control_keyword(
  keyword = list(
    c("amazon", "apple", "facebook", "google"),
    c("microsoft", "netflix", "twitter")
  ),
  time = "2016-01-01 2019-12-31"
)

# search topics
add_control_keyword(
  keyword = c("%2Fm%2F02q_bk", "%2Fm%2F055t58", "%2Fm%2F025sndk", "%2Fm%2F0d07ph", "%2Fm%2F09jcvs"),
  time = "2016-01-01 2019-12-31"
)
# This adds the following topics: Gmail, Google Maps, Google Translate, Wikipedia, YouTube

## End(Not run)


[Package globaltrends version 0.0.14 Index]