Package 'pulso'

Title: Load Microdata from Colombia's 'GEIH' ('DANE')
Description: Programmatic access to microdata from Colombia's Gran Encuesta Integrada de Hogares ('GEIH'), published by 'DANE'. Provides a tidy interface to download, parse, and harmonize labor market surveys from 2007 to present. R companion to the 'pulso-co' 'Python' package.
Authors: Esteban Labastidas [aut, cre]
Maintainer: Esteban Labastidas <[email protected]>
License: MIT + file LICENSE
Version: 0.3.0
Built: 2026-11-28 17:09:25 UTC
Source: https://github.com/stebandido77/pulso

Help Index


Clear the local pulso cache

Description

Deletes cached files under the pulso cache directory (tools::R_user_dir("pulso", "cache"), or the pulso.cache_dir option): the downloaded DANE zips ("raw"), the parsed modules stored as parquet ("parsed", only written when the 'arrow' package is installed), or both. Mirrors pulso.cache_clear() in 'Python'.

Usage

pulso_clear_cache(level = c("all", "raw", "parsed"))

Arguments

level

Character. One of "all" (default), "raw" or "parsed".

Value

Invisibly, the paths that were removed.

Examples

if (interactive()) {
  pulso_clear_cache("parsed")
}

Convert nominal peso columns to pesos of a reference month

Description

Adds <col>_real = nominal * IPC(deflate_to) / IPC(periodo of the row). Mirrors pulso.deflactar() in 'Python'.

Usage

pulso_deflactar(df, columns, deflate_to, periodo_col = "periodo", ipc_table = NULL)

Arguments

df

A data frame with a periodo ("YYYY-MM") column, e.g. from pulso_load_range.

columns

Character. Nominal peso columns to deflate.

deflate_to

Character. Reference month "YYYY-MM".

periodo_col

Character. Name of the period column.

ipc_table

Optional output of pulso_ipc.

Value

df with the <col>_real columns added.

Examples

df <- data.frame(periodo = "2018-12", inglabo = 1000)
pulso_deflactar(df, "inglabo", "2026-09", ipc_table = pulso_ipc(use_fixture = TRUE))

Describe a GEIH module

Description

Returns a human-readable summary of a GEIH survey module: its survey level, available epochs, and harmonized canonical variables.

Usage

pulso_describe(module)

Arguments

module

Character. Module name (e.g., "ocupados"). Must be one of the modules registered in sources.json.

Value

A multi-line character string.

Examples

pulso_describe("ocupados")

Describe metadata for a single column

Description

Pretty-prints metadata for a column in a tibble loaded with metadata = TRUE. Output format mirrors Python's pulso.describe_column().

Usage

pulso_describe_column(df, column)

Arguments

df

A tibble loaded with pulso_load(..., metadata = TRUE).

column

Character. Column name to describe.

Value

A multi-line character string.

Examples

if (interactive()) {
  df <- pulso_load(2024, 6, "ocupados", metadata = TRUE)
  cat(pulso_describe_column(df, "P6430"))
}

Describe a harmonized variable

Description

Returns a human-readable summary of a canonical variable defined in variable_map.json: its module, description, source mappings per epoch, and any comparability warning.

Usage

pulso_describe_variable(variable_name)

Arguments

variable_name

Character. Canonical variable name (e.g., "sexo"). The lookup is case-insensitive.

Value

A single multi-line character string.

Examples

pulso_describe_variable("sexo")
pulso_describe_variable("edad")

Labor-market indicators (TD, TO, TGP) by domain

Description

Computes the unemployment rate (TD), employment rate (TO) and global participation rate (TGP), plus the levels of the working-age population (PET), labor force (FT), employed and unemployed, with DANE's definitions: PET is 12+ in cabeceras and 10+ in centros poblados and rural disperso on the 2005 census frame, and 15+ on the 2018 frame (2022 onwards, and 2020); employed / unemployed / inactive come from DANE's per-module flags (OCI, DSI, INI on the 2005 frame; OCI, DSI, FFT on the 2018 frame). Mirrors pulso.indicadores() in 'Python'.

Point estimates only: the public GEIH microdata have no design variables (strata, PSU), so standard errors are not computed (se is NA). DANE publishes confidence limits and relative errors in the "Errores relativos" sheet of its monthly annex.

Usage

pulso_indicadores(
  start,
  end = NULL,
  dominio = c("nacional", "cabeceras", "centros_poblados_rural", "13_ciudades",
    "23_ciudades", "ciudad", "departamento"),
  trimestre_movil = FALSE,
  strict = FALSE,
  cache = TRUE
)

Arguments

start, end

Character "YYYY-MM". end defaults to start. With trimestre_movil = TRUE each row is the quarter ending in that month (e.g. "2026-09" = Jul-Sep 2026).

dominio

Character. One of "nacional", "cabeceras", "centros_poblados_rural", "13_ciudades", "23_ciudades" (cities with their metropolitan areas, DANE's AREA codes), "ciudad" (one row per AREA code) or "departamento" (one row per DPTO).

trimestre_movil

Logical. Pool each month with the two before it, with the expansion factor divided by 3. Default FALSE.

strict, cache

Passed to pulso_load_merged.

Value

A tibble with periodo, meses, dominio, grupo, pet, ft, oc, ds (persons), td, to, tgp (percent) and se (NA). Months that cannot be computed are skipped with a warning.

Examples

if (interactive()) {
  pulso_indicadores("2026-01", "2026-09")
  pulso_indicadores("2026-09", dominio = "ciudad", trimestre_movil = TRUE)
}

DANE's monthly CPI index (IPC total, base December 2018 = 100)

Description

Returns the IPC index as a tibble. Same interface as pulso_tpm: by default downloads the newest anex-IPC-Indices-<mes><anio>.xlsx linked from DANE's IPC page and falls back to a bundled snapshot (2003-01 to 2026-10). Mirrors pulso.ipc() in 'Python'.

Usage

pulso_ipc(use_fixture = NULL)

Arguments

use_fixture

Logical or NULL. NULL (default): try DANE, fall back to the snapshot. TRUE: always use the snapshot. FALSE: force the download.

Value

A tibble with periodo ("YYYY-MM"), anio, mes, indice.

Examples

if (interactive()) {
  tail(pulso_ipc())
}

List metadata for all columns of a tibble

Description

Returns a tibble summary of all columns with their metadata.

Usage

pulso_list_columns_metadata(df)

Arguments

df

A tibble loaded with pulso_load(..., metadata = TRUE).

Value

A tibble with columns: column, label, type, module, source, has_categories.

Examples

if (interactive()) {
  df <- pulso_load(2024, 6, "ocupados", metadata = TRUE)
  summary <- pulso_list_columns_metadata(df)
  print(summary)
}

List validated GEIH periods

Description

Returns the registry entries for which the downloaded data has been manually validated against DANE published figures.

Usage

pulso_list_validated_range()

Value

A tibble with one row per validated (year, month) pair, with columns: year (integer), month (integer), epoch (character), validated (logical, always TRUE), validated_at (character, ISO-8601 or NA), num_modules (integer). Sorted by year, month ascending.

Examples

pulso_list_validated_range()

List harmonized variables from the variable map

Description

Returns a tibble summarizing all canonical variables defined in variable_map.json, optionally filtered by module.

Usage

pulso_list_variables(module = NULL)

Arguments

module

Character or NULL. When non-NULL, restricts output to variables whose module field equals this value (exact match, case-sensitive). Available modules in the current variable map: caracteristicas_generales, desocupados, inactivos, ocupados, otros_ingresos, vivienda_hogares.

Value

A tibble with one row per variable and columns:

canonical_name

chr. Key used throughout the pulso package.

module

chr. Survey module the variable belongs to.

description_es

chr. Spanish description, or NA if absent.

comparability

chr. Always NA in this version (see Note).

has_warning

lgl. TRUE when a comparability_warning is present and non-empty for the variable.

num_epochs

int. Number of epoch mappings defined.

Rows are sorted ascending by canonical_name.

Note

The comparability column is always NA_character_ in the current version because the comparability field (expected values: "high" / "limited") has not yet been added to variable_map.json. Only comparability_warning (free text) is present in the data.

Examples

# All variables
pulso_list_variables()

# Subset by module
pulso_list_variables(module = "ocupados")

Load GEIH microdata for a single year-month-module

Description

Downloads and parses microdata from Colombia's Gran Encuesta Integrada de Hogares (GEIH), published by DANE.

Usage

pulso_load(
  year,
  month,
  module,
  area = NULL,
  harmonize = TRUE,
  cache = TRUE,
  metadata = FALSE,
  strict = FALSE,
  allow_unvalidated = NULL,
  columns = NULL
)

Arguments

year

Integer. Year (2007 to current year).

month

Integer. Month (1-12).

module

Character. Module name (e.g., "ocupados").

area

Character or NULL. Optional area filter. NOT IMPLEMENTED in v0.1.0.

harmonize

Logical. Whether to apply harmonization. Default TRUE.

cache

Logical. Whether to cache downloads. Default TRUE.

metadata

Logical. Whether to attach DANE metadata to result. Default FALSE for Python parity. When TRUE, attaches metadata via attr(df, "pulso_metadata") and triggers lazy download of codebook on first call.

strict

Logical. When FALSE (default, same as 'pulso-co' in 'Python'), periods not yet manually validated against DANE published figures are loaded with a one-time warning per period. When TRUE, such periods raise pulso_data_not_validated.

allow_unvalidated

Deprecated. Use strict instead (allow_unvalidated = FALSE is strict = TRUE).

columns

Character or NULL. Columns to keep (DANE names, matched case-insensitively; FEX_C also matches fex_c_2011). Only those columns are read from the file (data.table::fread(select =)). The merge keys (DIRECTORIO, SECUENCIA_P, ORDEN, HOGAR) are always kept so the result can still be merged. Requested columns that the file lacks are skipped with a warning. Default NULL (all columns).

Details

When cache = TRUE and the 'arrow' package is installed, the parsed module is also cached as parquet under the pulso cache directory, so the next load of the same period and module skips the zip and the CSV parsing. The cache key includes the download URL, the module, the parser version and the period's catalog entry. Without 'arrow' nothing changes. Clear it with pulso_clear_cache("parsed").

Value

A tibble with the microdata. If metadata = TRUE, the tibble has an attribute "pulso_metadata" with structured column info.

Examples

if (interactive()) {
  df <- pulso_load(year = 2024, month = 6, module = "ocupados",
                   metadata = TRUE)
  cat(pulso_describe_column(df, "P6430"))
}

Load and merge GEIH microdata across multiple modules

Description

Downloads, parses, and joins microdata from multiple GEIH modules for a single year-month. All modules must be at the same survey level (persona or hogar).

Usage

pulso_load_merged(
  year,
  month,
  modules,
  harmonize = TRUE,
  cache = TRUE,
  metadata = FALSE,
  strict = FALSE,
  allow_unvalidated = NULL
)

Arguments

year

Integer. Year (2007 to current year).

month

Integer. Month (1-12).

modules

Character vector. Module names to merge (length >= 2). Use pulso_load for a single module.

harmonize

Logical. Whether to lowercase column names. Default TRUE.

cache

Logical. Whether to cache downloads. Default TRUE.

metadata

Logical. Whether to attach DANE metadata. Default FALSE. When TRUE, metadata is composed from the first module's column index (multi-module metadata composition is planned for a future release).

strict

Logical. Passed through to each pulso_load(). Default FALSE: unvalidated periods load with a warning.

allow_unvalidated

Deprecated; see pulso_load.

Value

A tibble with columns from all requested modules, joined on shared identifier keys (directorio, secuencia_p, orden for persona-level modules). The join is an outer join by default so that modules covering different person subsets (e.g., ocupados vs desocupados) are combined correctly.

Note

Mixed-level merges (persona + hogar modules in the same call) are deferred to v0.2.0. If you need a hogar-level module, merge the result manually after separate calls.

Examples

if (interactive()) {
  df <- pulso_load_merged(2024, 6, c("ocupados", "caracteristicas_generales"))
  nrow(df)
}

Load consecutive months of a GEIH module

Description

Loads every month from start to end with pulso_load and stacks them with a periodo column ("YYYY-MM"). Mirrors pulso.load_range() in 'Python'.

Usage

pulso_load_range(
  start,
  end,
  module,
  harmonize = TRUE,
  cache = TRUE,
  strict = FALSE,
  columns = NULL,
  average_weights = FALSE,
  deflate_to = NULL,
  income_columns = NULL
)

Arguments

start, end

Character. Inclusive bounds, "YYYY-MM".

module

Character. Module name (e.g., "ocupados").

harmonize, cache, strict, columns

Passed to pulso_load.

average_weights

Logical. If TRUE, add peso_expansion_promedio = expansion factor / number of months loaded. Each monthly file expands to the whole population, so pooling several months with the raw factor counts everyone once per month; DANE's moving-quarter levels (sheet "Total nacional Trim" of anex-GEIH-<mes><anio>.xlsx) are the average of the monthly levels, i.e. factor / 3. Rates (TD, TO, TGP) are the same with either factor. Default FALSE.

deflate_to

Character or NULL. If given ("YYYY-MM"), add <col>_real columns in pesos of that month with DANE's IPC (pulso_deflactar).

income_columns

Character or NULL. Columns to deflate. Default: inglabo (or INGLABO) when present.

Details

A warning is raised when the range mixes microdata on the 2005 and the 2018 census frames (2022-01 onwards, and 2020, whose files DANE re-weighted to the 2018 census): levels and rates are not comparable across frames.

Value

A tibble with periodo, year and month columns plus the module's columns (columns missing in some months are NA there).

Examples

if (interactive()) {
  oc <- pulso_load_range("2026-07", "2026-09", "ocupados",
                         average_weights = TRUE)
  sum(oc$peso_expansion_promedio)  # moving-quarter employed population
}

Monthly legal minimum wage (SMMLV) by year

Description

Bundled table of Colombia's monthly legal minimum wage (without the transport allowance), 2007-2026, with the decree that set each value and the official page where it was verified. Mirrors pulso.salario_minimo() in 'Python'.

Usage

pulso_salario_minimo()

Value

A tibble with anio, smmlv, decreto, fuente.

Examples

pulso_salario_minimo()

Fetch Tasa de Politica Monetaria (TPM) from Banco de la Republica

Description

Returns Colombia's monetary policy rate as a tibble. Data source: Banco de la Republica SDMX API (DF_CBR_DAILY_HIST). When the API is unavailable, falls back to a bundled snapshot extending to 2026-04-21.

Usage

pulso_tpm(start = NULL, end = NULL, use_fixture = NULL)

Arguments

start

Optional start date as character "YYYY-MM-DD" or Date.

end

Optional end date as character "YYYY-MM-DD" or Date.

use_fixture

Logical or NULL. If NULL (default), auto-detect: tries API first, falls back to snapshot if unavailable. If TRUE, always use bundled snapshot. If FALSE, force API call.

Value

A tibble with columns:

fecha

Date. Observation date.

valor

numeric. TPM rate in percentage points.

serie

character. Always "tpm".

Examples

if (interactive()) {
  # Recent TPM
  tpm_2024 <- pulso_tpm(start = "2024-01-01", end = "2024-12-31")
  # Full history (uses fixture if API down)
  tpm_all <- pulso_tpm()
}

Fetch the TRM (COP per USD) certified by the Superintendencia Financiera

Description

Returns Colombia's Tasa Representativa del Mercado as a tibble with one row per calendar day. Data source: the Superintendencia Financiera's dataset on datos.gov.co (32sa-8pi3); the Superfinanciera is the entity that certifies the TRM. Each certified value covers a validity window (Friday's value covers the weekend), which is expanded to days. When the live call fails, falls back to a bundled snapshot extending to 2026-11-30. Same interface as pulso_tpm; mirrors pulso.trm() in 'Python'.

Usage

pulso_trm(start = NULL, end = NULL, use_fixture = NULL)

Arguments

start

Optional start date as character "YYYY-MM-DD" or Date.

end

Optional end date as character "YYYY-MM-DD" or Date.

use_fixture

Logical or NULL. If NULL (default), try the live dataset and fall back to the snapshot. If TRUE, always use the bundled snapshot. If FALSE, force the live call (errors if it fails).

Value

A tibble with columns:

fecha

Date. Calendar day.

valor

numeric. Pesos per US dollar.

serie

character. Always "trm".

Examples

if (interactive()) {
  trm_2026 <- pulso_trm(start = "2026-01-01", end = "2026-09-30")
}

Update the catalog of DANE releases

Description

DANE publishes a new GEIH month roughly every four weeks, faster than package releases reach CRAN. This downloads the catalog maintained in the pulso repository (refreshed monthly) into the user cache, so new months become loadable without upgrading the package. The catalog is only replaced when the download is valid and covers a later period than the one in use.

Usage

pulso_update_catalog(
  url = "https://raw.githubusercontent.com/Stebandido77/pulso/main/data/sources.json"
)

Arguments

url

Character. Catalog URL. Defaults to the main branch of the pulso repository on GitHub.

Value

Invisibly, a list with previous_end, latest_end, n_periods and path (where the catalog was saved, or NULL if it was not newer).

Examples

if (interactive()) {
  pulso_update_catalog()
}

Validation status for a GEIH period

Description

Returns structured metadata about a specific year-month entry in the pulso registry, including whether it has been manually validated against published DANE figures.

Usage

pulso_validation_status(year, month)

Arguments

year

Integer. Year (2007 to current year).

month

Integer. Month (1-12).

Value

A one-row tibble with columns: year, month, epoch, validated, validated_by, validated_at, source_url, file_size_mb, modules_available, checksum_sha256.

Examples

pulso_validation_status(2024, 6)