Package 'CepalStatR'

Title: Access to the 'CEPALSTAT API'
Description: Explore metadata and retrieve indicators from the statistical portal of the Economic Commission for Latin America and the Caribbean <https://statistics.cepal.org/portal/cepalstat/>. Provides a reproducible interface to access the 'CEPALSTAT API', organize data into tidy formats, and generate both static and interactive visualizations.
Authors: Henry Osorto [aut, cre] (ORCID: <https://orcid.org/0000-0002-4334-9179>)
Maintainer: Henry Osorto <[email protected]>
License: MIT + file LICENSE
Version: 0.9.0
Built: 2026-06-06 05:54:13 UTC
Source: https://github.com/cran/CepalStatR

Help Index


Call Data Indicators CEPALSTAT

Description

Retrieves indicator data from the CEPALSTAT API in JSON format and returns a data frame with values, dimensions, metadata, and optionally footnotes.

Usage

call.data(id.indicator, language.en = TRUE, notes = FALSE,
                 progress = TRUE, add.indicator.name = TRUE)

Arguments

id.indicator

A single CEPALSTAT indicator ID.

language.en

Logical. If TRUE (default), the output uses English labels. If FALSE, Spanish labels are used when applicable.

notes

Logical. If TRUE, footnotes are joined when available.

progress

Logical. If TRUE, progress messages are shown.

add.indicator.name

Logical. If TRUE, adds indicator ID and indicator name.

Value

A data frame with indicator values, dimension labels, and metadata.

Examples

data <- call.data(id.indicator = 4788)
data <- call.data(id.indicator = 4788, language.en = FALSE)
data <- call.data(id.indicator = 4788, notes = TRUE)

Call indicators from CEPALSTAT

Description

Retrieves the thematic tree from the CEPALSTAT API in JSON format and returns a data frame with the hierarchical structure of indicators.

Usage

call.indicators(language.en = TRUE, progress = TRUE)

Arguments

language.en

Logical. If TRUE (default), labels are returned in English. If FALSE, labels are returned in Spanish.

progress

Logical. If TRUE (default), progress messages are displayed.

Value

A data frame with the hierarchical thematic structure of CEPALSTAT indicators and the corresponding indicator ID.

Examples

data.indicators <- call.indicators()
data.indicators <- call.indicators(language.en = FALSE)

List of countries available in CEPALSTAT

Description

Retrieves the list of countries available in CEPALSTAT using the dimensions endpoint of a reference indicator. This approach avoids downloading full datasets and ensures consistency with the API structure.

Usage

countries(language.en = TRUE)

Arguments

language.en

Logical. If TRUE (default), returns country names in English. If FALSE, returns names in Spanish.

Value

A data frame containing the list of countries.

Examples

countries()
countries(language.en = FALSE)

Population pyramids

Description

Creates one or multiple population pyramids for a selected country and years using CEPALSTAT population-by-age-and-sex data.

Usage

pyramids(
  country,
  years = 1:31,
  language.en = TRUE,
  color = c("#0C4A61", "#34B0AA"),
  save = FALSE,
  file = NULL,
  format = c("png", "pdf", "svg"),
  height = 5,
  width = 7,
  caption = TRUE,
  progress = TRUE
)

Arguments

country

Character. Name of the country or region to plot.

years

Numeric vector of positions between 1 and 31 corresponding to 5-year intervals from 1950 to 2100.

language.en

Logical. If TRUE (default), English labels are used. If FALSE, Spanish labels are used.

color

Character vector of length 2 with colors for men and women.

save

Logical. If TRUE, saves the resulting figure.

file

Character. Output filename when save = TRUE. If NULL, the file is saved to a temporary directory using tempdir().

format

Character. Output format when save = TRUE. One of "png" (default), "pdf" or "svg".

height

Numeric. Height of saved figure.

width

Numeric. Width of saved figure.

caption

Logical. If TRUE, adds a caption with source information.

progress

Logical. If TRUE, progress messages are shown.

Value

Invisibly returns a grob object created by gridExtra::arrangeGrob().

Examples

# Single year
pyramids(country = "Honduras", years = 16)

# Multiple years
pyramids(country = "Honduras", years = c(1, 5, 10, 15))

#' # Save as PNG
pyramids(country = "Honduras",
         years = c(1, 5, 10, 15),
         save = TRUE,
         file = file.path(tempdir(), "pyramids.png"))

# Save as PDF
pyramids(country = "Honduras",
         years = c(1, 5, 10, 15),
         save = TRUE,
         format = "pdf",
         file = file.path(tempdir(), "pyramids.pdf"))

# Save as SVG
pyramids(country = "Honduras",
         years = c(1, 5, 10, 15),
         save = TRUE,
         format = "svg",
         file = file.path(tempdir(), "pyramids.svg"))

Sustainable Development Goals ranking

Description

Creates a ranking chart for a CEPALSTAT indicator belonging to the Sustainable Development Goals (SDG/ODS) dimension, using the latest available data by country.

Usage

ranking.sdg(
  id.indicator,
  language.en = TRUE,
  save = FALSE,
  file = NULL,
  format = c("png", "pdf", "svg"),
  height = 5,
  width = 9,
  size.title = 10,
  title = TRUE,
  caption = TRUE,
  color = "#0C4A61",
  color.gc = "#34B0AA",
  progress = TRUE
)

Arguments

id.indicator

Numeric or character. Indicator ID.

language.en

Logical. If TRUE (default), English labels are used. If FALSE, Spanish labels are used.

save

Logical. If TRUE, saves the resulting figure.

file

Character. Output filename when save = TRUE. If NULL, the file is saved to a temporary directory using tempdir().

format

Character. Output format when save = TRUE. One of "png" (default), "pdf" or "svg".

height

Numeric. Height of saved figure.

width

Numeric. Width of saved figure.

size.title

Numeric. Title size.

title

Logical. If TRUE, displays the chart title.

caption

Logical. If TRUE, displays a note indicating the latest available year by country.

color

Character. Color for countries in the ranking.

color.gc

Character. Color for regional aggregates if present.

progress

Logical. If TRUE, shows progress messages during execution.

Value

Invisibly returns a ggplot object.

Examples

ranking.sdg(id.indicator = 3682)

ranking.sdg(id.indicator = 3682, language.en = FALSE)

ranking.sdg(id.indicator = 3682,
            save = TRUE,
            file = file.path(tempdir(), "ranking_sdg.png"))

ranking.sdg(id.indicator = 3682,
            save = TRUE,
            format = "pdf",
            file = file.path(tempdir(), "ranking_sdg.pdf"))

ranking.sdg(id.indicator = 3682,
            save = TRUE,
            format = "svg",
            file = file.path(tempdir(), "ranking_sdg.svg"))

CEPALSTAT thematic map of indicators

Description

Creates an interactive thematic tree of CEPALSTAT indicators using collapsibleTree, with the same visual header and footer style as viewer.indicators().

Usage

topic_map(language.en = TRUE, progress = TRUE, open.browser = FALSE)

Arguments

language.en

Logical. If TRUE (default), English labels are used. If FALSE, Spanish labels are used.

progress

Logical. If TRUE, progress messages are shown.

open.browser

Logical. If TRUE, the generated HTML is saved to a temporary file and opened in the default web browser. Defaults to FALSE.

Value

A browsable HTML widget.

Examples

topic_map()

topic_map(language.en = FALSE)

Viewer for CEPALSTAT indicators

Description

Displays an interactive HTML table for browsing the hierarchical structure of CEPALSTAT indicators using call.indicators() as backend.

Usage

viewer.indicators(
  language.en = TRUE,
  progress = TRUE,
  show_search = TRUE,
  striped = TRUE,
  bordered = FALSE,
  compact = FALSE,
  highlight = TRUE,
  full_width = TRUE,
  page_size = 15,
  open.browser = FALSE
)

Arguments

language.en

Logical. If TRUE (default), the viewer uses English labels. If FALSE, Spanish labels are used.

progress

Logical. If TRUE, progress messages are shown.

show_search

Logical. If TRUE, enables global search in the table.

striped

Logical. If TRUE, striped rows are shown.

bordered

Logical. If TRUE, table borders are shown.

compact

Logical. If TRUE, reduces row padding.

highlight

Logical. If TRUE, highlights rows on hover.

full_width

Logical. If TRUE, table uses full available width.

page_size

Integer. Number of rows to show per page.

open.browser

Logical. If TRUE, the generated HTML is saved to a temporary file and opened in the default web browser. Defaults to FALSE.

Value

A browsable HTML object containing the header and interactive table.

Examples

viewer.indicators()
viewer.indicators(language.en = FALSE)
viewer.indicators(open.browser = TRUE)