Learn R Programming

globaltrends (version 0.0.14)

export_control: Export data from database table

Description

The function allows to export data from database tables. In combination with various write functions in R, the functions allow exports from the database to local files.

Usage

export_control(control = NULL, location = NULL)

export_control_global(control = NULL)

export_object(keyword = NULL, object = NULL, control = NULL, location = NULL)

export_object_global(keyword = NULL, object = NULL, control = NULL)

export_score(keyword = NULL, object = NULL, control = NULL, location = NULL)

export_voi(keyword = NULL, object = NULL, control = NULL)

export_doi( keyword = NULL, object = NULL, control = NULL, locations = NULL, type = c("obs", "sad", "trd") )

Value

The functions export and filter the respective database tables.

  • export_control and export_control_global export data from table *data_controlwith columns location, keyword, date, hits, control. Object of class"data.frame". Methods are applied based on input *control*. \item export_objectandexport_object_global export data from table *data_object with columns location, keyword, date, hits, object. Object of class "data.frame". Methods are applied based on input keyword.

  • export_score exports data from table *data_scorewith columns location, keyword, date, score_obs, score_sad, score_trd, control, object. Object of classc("exp_score", "data.frame"). Methods are applied based on input *keyword*. \item export_voi exports data from table *data_score with columns keyword, date, hits, control, filters for location == "world". Object of class c("exp_voi", "data.frame"). Methods are applied based on input keyword.

  • export_doi exports data from table *data_doiwith columns keyword, date, type, gini, hhi, entropy, control, object, locations. Object of classc("exp_doi", "data.frame")`. Methods are applied based on input keyword.

Arguments

control

Control batch number for which data should be exported. Only for export_control and export_control_global, input is also possible as list.

location

List of locations for which the data is exported. Refers to lists generated in start_db or character objects in these lists. Only for export_control, export_object, or export_score.

keyword

Object keywords for which data should be exported. Object or list of objects of type character.

object

Object batch number for which data should be exported.

locations

List of locations for which the data is exported. Refers to names of lists generated in start_db as an object of type character. Only for export_doi.

type

Type of time series for which data should be exported. Element of type character. Relevant only for export_global and export_doi. Takes one of the following values: obs - observed search scores, sad - seasonally adjusted search scores, trd - trend only search scores.

Details

Exports can be filtered by keyword, object, control, location, locations, or type. Not all filters are applicable for all functions. When filter keyword and object are used together, keyword overrules object. When supplying NULL as input, no filter is applied to the variable.

See Also

  • example_control()

  • example_object()

  • example_score()

  • example_doi()

Examples

Run this code
if (FALSE) {
export_control(control = 2)

export_object(
  keyword = "manchester united",
  locations = countries
)

export_object(
  keyword = c("manchester united", "real madrid")
)

export_object(
  keyword = list("manchester united", "real madrid")
)

export_score(
  object = 3,
  control = 1,
  location = us_states
) %>%
  readr::write_csv("data_score.csv")

export_doi(
  keyword = "manchester united",
  control = 2,
  type = "sad",
  locations = "us_states"
) %>%
  writexl::write_xlsx("data_doi.xlsx")
}

Run the code above in your browser using DataLab