download_object {globaltrends}R Documentation

Download data for object batch

Description

The function downloads search volumes from Google Trends for an object batch (batch_o) and one keyword from a control batch (batch_c) in a set of locations. Data is automatically written to table data_object. For download_object_global the input location is automatically set to world.

Usage

download_object(object, control = 1, locations = gt.env$countries, ...)

## S3 method for class 'numeric'
download_object(object, control = 1, locations = gt.env$countries, ...)

## S3 method for class 'list'
download_object(object, control = 1, locations = gt.env$countries, ...)

download_object_global(object, control = 1, ...)

Arguments

object

Object batch for which the data is downloaded. Object of type numeric or object of type list containing single object of type numeric.

control

Control batch that is used for mapping. Object of type numeric. Defaults to 1.

locations

List of countries or regions for which the data is downloaded. Refers to lists generated in start_db. Defaults to countries.

...

Arguments that are passed on to the gtrendsR::gtrends function.

Details

Downloads through the Google Trends API are made through gtrendsR::gtrends. Each object batch can consist of up to four keywords and is predefined in tables batch_keywords and batch_time through add_keywords. In addition, one control keyword is added to each object batch. The control keyword then allows a mapping between search volumes for control keywords stored in data_control and search volumes for object keywords. The download for a single keyword batch for a single location takes about 30 seconds. This includes a randomized waiting period of 5-10 seconds between downloads. Depending on the frequency of downloads, Google Trends might block users for some time. In this case, download_object waits 60 minutes before it retries the download.

Value

Message that data was downloaded successfully. Data is written to table data_object.

Warning

We advise against the usage of category codes in downloads. If you use categories to narrow the context of keyword usage, these categories are applied to ALL keywords in the batch. This applies to control keywords as well as object keywords and can result in unintended behavior.

See Also

Examples

## Not run: 
download_object(
  object = 1,
  locations = countries
)
download_object(
  object = as.list(1:5),
  locations = countries
)

## End(Not run)


[Package globaltrends version 0.0.14 Index]