get_data_table | R Documentation |
Get data from a specific table
get_data_table(
idTable = NULL,
filter = NULL,
nlast = NULL,
dateStart = NULL,
dateEnd = NULL,
det = 0,
tip = NULL,
lang = "ES",
validate = TRUE,
verbose = FALSE,
unnest = FALSE,
metanames = FALSE,
metacodes = FALSE
)
idTable |
(int): id of the table. For further information about ids click this link. |
filter |
(list): list of variables and values. Filtering data from tablesWhen we request data from tables there is the possibility of filtering data
on the fly using metadata information about the variables and their values
that define the series. See Case one: tempus tableURL example.
For a tempus table the filter is based on ids. The format is
Case two: px tablesURL example.
For a px table the filter is based on codes. The format is
Case three: tpx tableURL example.
For a tpx table the filter is based on codes. The format is
URL example.
There are tpx tables that contain variable ids and value ids. In this case,
we can use the ids instead of the codes to build the filter. To do this we add
the alias ~id at the end of each id: Using shortcutsAdditionally, shortcuts can be used to filter. They simplify the filtering
approach by using standardized names for variable IDs and therefore simplify
their use. The format for a tempus table is:
|
nlast |
(int): number of periods to retrieve. By default it retrieves all available periods. |
dateStart |
(string): the initial date of the requested data. The required format is yyyy/mm/dd. Additionally, dateStart can be a vector of dates, where each date represents the start date of individual ranges where the end date should be found at the same position in the dateEnd vector. If dateStart and dateEnd are equal, the specified dates are retrieved. If no end date is entered, all dates will be queried, from the corresponding start date to the last available period. |
dateEnd |
(string): the end date of the requested data. The required format is yyyy/mm/dd. Additionally, dateEnd can be a vector of dates, where each date represents the end date of individual ranges where the initial date should be found at the same position in the dateStart vector. The length of the dateEnd vector must be less than or equal to the length of the dateStart vector. |
det |
(int): level of detail. Valid values: 0, 1 or 2. |
tip |
(string): set to 'A' for friendly output (e.g. readable dates), set to 'M' to include metadata or set to 'AM' for both. |
lang |
(string): language of the retrieved data. Set to 'ES' for Spanish or set to 'EN' for English. |
validate |
(logical): validate the input parameters. A FALSE value means fewer API calls. Therefore, it is recommended to set it to FALSE when there is no doubt about the validity of the input parameters, including the filter. |
verbose |
(logical): print additional information, including the URL to call the API service. |
unnest |
(logical): set to TRUE to obtain a single data frame of data. |
metanames |
(logical): set to TRUE to extract the name of the values that defined the table. The names are extracted from the metadata information (it is mandatory to include 'M' in the tip parameter). Several columns are created corresponding to the values of the different variables. |
metacodes |
(logical): set to TRUE to extract the codes and ids of the values that defined the table. The codes and ids are extracted from the metadata information (it is mandatory to include 'M' in the tip parameter). Several columns are created corresponding to the values of the different variables. |
Data frame with data of a table according to the id specified in the function
# Obtaining the last two periods and filter data
filter <- list("3" = "74", "762" = "304092")
df <-get_data_table(idTable = 50902, nlast = 2, unnest = TRUE,
filter = filter, validate = FALSE)
head(df)
# Get data for an open range date
df <- get_data_table(idTable = 50902, unnest = TRUE, tip= "A",
filter = filter, validate = FALSE,
dateStart = "2025/01/01")
head(df)
# Get data for a single range data
df <- get_data_table(idTable = 50902, unnest = TRUE, tip= "A",
filter = filter, validate = FALSE,
dateStart = "2023/01/01", dateEnd = "2023/05/01")
head(df)
# Get data for specific dates
df <- get_data_table(idTable = 50902, unnest = TRUE, tip= "A",
filter = filter, validate = FALSE,
dateStart = c("2023/01/01","2024/01/01"),
dateEnd = c("2023/01/01","2024/01/01"))
head(df)
# Get data for multiple date ranges
df <- get_data_table(idTable = 50902, unnest = TRUE, tip= "A",
filter = filter, validate = FALSE,
dateStart = c("2023/01/01","2024/01/01"),
dateEnd = c("2023/03/01","2024/03/01"))
head(df)
# Get medatada as well
df <- get_data_table(idTable = 50902, nlast = 2, unnest = TRUE,
filter = filter, validate = FALSE,
metanames = TRUE, metacodes = TRUE, tip = "M")
head(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.