Fetch Rolling Quarter Series from SIDRA
Source:R/fetch-sidra-series.R
fetch_sidra_rolling_quarters.RdDownloads PNADC labor market indicators from IBGE's SIDRA API. These series are published as rolling quarterly averages (trimestre movel), with 12 observations per year.
Usage
fetch_sidra_rolling_quarters(
series = "all",
theme = NULL,
theme_category = NULL,
subcategory = NULL,
exclude_derived = FALSE,
use_cache = FALSE,
verbose = TRUE,
retry_failed = TRUE,
max_retries = 3
)Arguments
- series
Character vector of series names to fetch, or "all" (default) for all available series. Use
get_sidra_series_metadata()$series_nameto see available names.- theme
Character vector of themes to filter by. Valid options: "labor_market", "earnings", "demographics", "social_protection", "prices". Use NULL for no filter.
- theme_category
Character vector of theme categories to filter by. Use NULL for no filter.
- subcategory
Character vector of subcategories to filter by. Use NULL for no filter.
- exclude_derived
Logical. If TRUE, exclude series marked as derived (is_derived = TRUE in metadata). Default FALSE for backward compatibility. Derived series (rates) are computed from other series during mensalization, so excluding them saves API calls when fetching for mensalization.
- use_cache
Logical. Use cached data if available? Default FALSE. When TRUE, shows the date when data was cached (may be outdated). Use
clear_sidra_cacheto force fresh download.- verbose
Logical. Print progress messages? Default TRUE.
- retry_failed
Logical. Retry failed series downloads? Default TRUE.
- max_retries
Integer. Maximum retry attempts per series. Default 3.
Value
A data.table with columns:
- anomesfinaltrimmovel
Integer. YYYYMM of rolling quarter end month
- mesnotrim
Integer. Month position in quarter (1, 2, or 3)
- <series_name>
Numeric. One column per requested series
Details
Rolling quarters are labeled by their ending month:
201201 = Nov 2011 - Jan 2012 (mesnotrim = 1)
201202 = Dec 2011 - Feb 2012 (mesnotrim = 2)
201203 = Jan - Mar 2012 (mesnotrim = 3)
201204 = Feb - Apr 2012 (mesnotrim = 1)
etc.
The mesnotrim column indicates the month's position within its rolling
quarter, which is essential for the mensalization algorithm.
Rate Limiting
SIDRA API may have rate limits. The function includes automatic retry logic with exponential backoff for failed requests.
See also
get_sidra_series_metadata for available series names and metadata
mensalize_sidra_series to convert to exact months
Examples
if (FALSE) { # \dontrun{
# Fetch all series (may take several minutes on first call)
rq <- fetch_sidra_rolling_quarters()
# Fetch only labor market series
rq_labor <- fetch_sidra_rolling_quarters(theme = "labor_market")
# Fetch only unemployment data
rq_unemp <- fetch_sidra_rolling_quarters(theme = "labor_market",
theme_category = "unemployment")
# Fetch specific series
rq <- fetch_sidra_rolling_quarters(
series = c("taxadesocup", "popocup", "popdesocup")
)
} # }