How tidy-intelligence/r-owidapi works
This project is an R package that provides a client interface to the Our World in Data (OWID) Chart API. Its primary purpose is to allow users—economists, financial professionals, and data scientists—to retrieve chart data (including life expectancy, COVID-19 vaccination data, etc.), fetch metadata, and even embed interactive charts directly into web or Shiny applications. The package, as part of the econdataverse suite, serves as a tool to simplify the process of working with global datasets available on the OWID platform.
Main Components
• Core R Functions – Represented in the “R” directory. This contains functions such as owid_get, owid_search, owid_embed, owid_render, and helper functions (e.g., perform_request) that encapsulate the API calls and data transformation logic.
• Documentation & Metadata – Captured by the “man” directory (with Rd files and figures) and the README files that describe usage examples and package details.
• Testing Suite – Shown by the “tests” directory (using testthat) to validate the package functionality.
• CI/CD and Build Infrastructure – Highlight the GitHub workflow files found under “.github/workflows” which perform R CMD check, linting, pkgdown site generation, and test coverage monitoring.
• Package Metadata and Configuration – Include the DESCRIPTION, NAMESPACE, and other configuration files (e.g., .Rbuildignore, _pkgdown.yml) that define the package environment and build settings.
Relationships & Data Flow
• API Interaction: Map how the core functions call the underlying perform_request method to send HTTP requests to the external OWID API endpoints and retrieve JSON/data responses.
• Data Processing & Presentation: Show how the retrieved data is converted into tibbles (data frames) and how metadata is processed (e.g., metadata retrieval functions) before being usable by the end user.
• Testing & CI/CD Pipeline: Illustrate how the testing suite interacts with the package code (executing unit tests) and how GitHub Actions orchestrates code quality checks, linting, and package builds.
• Documentation Build: Connect the pkgdown workflow to the documentation in “man”, which is automatically updated and published.
Architectural Patterns and Design Principles
• Modular Design: The package is structured in a modular way with separate files for individual API functions, helper utilities, and testing scripts. This modularity can be highlighted with distinct components or sub-systems.
• Separation of Concerns: There is a clear separation between the core functionality (API calls and data processing) and the user interface layers (e.g., output functions for embedding charts).
• CI/CD Integration: Emphasize the integration of automated workflows from GitHub which support continuous integration, deployment, and documentation building.
Technologies, Frameworks, and Libraries
• Testthat: For unit testing within the “tests” directory.
• GitHub Actions: For orchestration of CI tools like R CMD check, lint tests, and package documentation builds.
• Shiny: Mark optional Shiny integration components (using functions like owid_output and owid_server) which indicate how charts can be embedded in interactive applications.
• OWID API: External dependency—the HTTP requests interacting with the Our World in Data API endpoints must be clearly delineated.