Changelog
Source:NEWS.md
rTrafa 0.1.0
Initial CRAN release.
Features
-
API connection:
trafa_available()performs a lightweight connectivity check, used to guard examples and tests. -
Product discovery:
get_products()lists all statistical products (datasets) available on the Trafa API. -
Structure inspection:
get_measures()andget_dimensions()retrieve the measures (KPIs) and filterable dimensions for a given product, including hierarchy metadata and dimension validation. -
Data retrieval:
get_data()downloads data using pipe-delimited query syntax, with automatic parsing and optional simplification (human-readable_labelcolumns alongside raw codes). -
Query workflow:
prepare_query()validates selections against the structure endpoint before hitting the data endpoint;compose_structure_query()andcompose_data_query()expose programmatic access to the raw URL builders. -
Entity operations: each entity type (
product,measure,dimension) supports a consistent family of*_search(),*_describe(),*_extract_ids()/*_extract_names()and*_minimize()helpers for piped exploration. -
Filter shortcuts:
dimension_values()surfaces Trafa’s server-side shortcuts (senaste,forra) alongside regular values, so queries can always reach the latest period without hardcoding years. -
Data helpers:
data_minimize()drops monotonous columns;data_legend()generates a source caption suitable forggplot2::labs(caption = ...), withlang,omit_varnameandomit_descarguments for fine-grained control over what to show. -
Persistent caching:
trafa_cache_dir()andtrafa_clear_cache()manage cached API responses viatools::R_user_dir(). - HTTP resilience: automatic retry with exponential backoff for transient errors.
-
Offline-safe: all examples and vignettes are guarded by
trafa_available()and draw on pre-cached API data stored inR/sysdata.rda, so package builds and tests do not require network access.
Documentation
-
Quick start vignette (
a-quickstart-rtrafa): five-step walk-through from product discovery to a plotted time series. -
Introduction vignette (
introduction-to-rtrafa): covers the four-level data model (product → measure → dimension → value), hierarchies, filter shortcuts, dimension validation, prepared queries, and three worked ggplot2 examples. - Vignette plots convert the
ar(year) column toDatebefore plotting and usescale_x_date()so axis breaks land on whole years — a pattern the sibling packagesrKoladaandpixiewebshare. - README and vignettes cross-link to the sibling packages
rKolada(Swedish municipal and regional KPIs) andpixieweb(PX-Web APIs for Nordic statistics agencies).