| Title: | Access to the 'CEPALSTAT API' |
| Version: | 0.9.0 |
| 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. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/Henry-Osorto/CepalStatR, https://henry-osorto.github.io/CepalStatR/ |
| BugReports: | https://github.com/Henry-Osorto/CepalStatR/issues |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.1) |
| Imports: | base64enc, dplyr, httr2, htmltools, jsonlite, magrittr, reactable, stringr, tidyselect, rlang, collapsibleTree, gridExtra, htmlwidgets |
| Suggests: | ggplot2, gt, knitr, rmarkdown, svglite, testthat (≥ 3.0.0), vcr, webmockr |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | no |
| Packaged: | 2026-05-05 05:00:20 UTC; henry |
| Author: | Henry Osorto |
| Maintainer: | Henry Osorto <henry.osorto@unah.edu.hn> |
| Repository: | CRAN |
| Date/Publication: | 2026-05-07 16:43:28 UTC |
CepalStatR: 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.
Author(s)
Maintainer: Henry Osorto henry.osorto@unah.edu.hn (ORCID)
See Also
Useful links:
Report bugs at https://github.com/Henry-Osorto/CepalStatR/issues
Pipe operator
Description
See magrittr::%>% for details.
Usage
lhs %>% rhs
Arguments
lhs |
A value or the magrittr placeholder. |
rhs |
A function call using the magrittr semantics. |
Value
The result of calling rhs(lhs).
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 |
notes |
Logical. If |
progress |
Logical. If |
add.indicator.name |
Logical. If |
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 |
progress |
Logical. If |
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)
Internal helper to retrieve CEPALSTAT resources
Description
Internal helper to retrieve CEPALSTAT resources
Usage
cepal_get(url, format = c("json", "csv"), timeout_sec = 60)
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)
Convert an image file to a data URI
Description
Convert an image file to a data URI
Usage
img_to_data_uri(path)
Arguments
path |
Path to the image file. |
Value
A character string containing a data URI, or NULL if the file does not exist.
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 |
color |
Character vector of length 2 with colors for men and women. |
save |
Logical. If |
file |
Character. Output filename when |
format |
Character. Output format when |
height |
Numeric. Height of saved figure. |
width |
Numeric. Width of saved figure. |
caption |
Logical. If |
progress |
Logical. If |
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 |
save |
Logical. If |
file |
Character. Output filename when |
format |
Character. Output format when |
height |
Numeric. Height of saved figure. |
width |
Numeric. Width of saved figure. |
size.title |
Numeric. Title size. |
title |
Logical. If |
caption |
Logical. If |
color |
Character. Color for countries in the ranking. |
color.gc |
Character. Color for regional aggregates if present. |
progress |
Logical. If |
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 |
progress |
Logical. If |
open.browser |
Logical. If |
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 |
progress |
Logical. If |
show_search |
Logical. If |
striped |
Logical. If |
bordered |
Logical. If |
compact |
Logical. If |
highlight |
Logical. If |
full_width |
Logical. If |
page_size |
Integer. Number of rows to show per page. |
open.browser |
Logical. If |
Value
A browsable HTML object containing the header and interactive table.
Examples
viewer.indicators()
viewer.indicators(language.en = FALSE)
viewer.indicators(open.browser = TRUE)
CSS for viewer.indicators header layout
Description
CSS for viewer.indicators header layout
Usage
viewer_indicators_style()
Value
An htmltools style tag.