Skip to contents

This guide covers how to set up, build, test, and document the openaq R package locally.

Prerequisites

  • R >= 4.1.0
  • devtools
  • roxygen2
  • An OpenAQ API key set as the environment variable OPENAQ_API_KEY

Getting Started

Clone the repository and install dependencies:

install.packages("devtools")
devtools::install_deps(dependencies = TRUE)

Building

Build the package tarball:

R CMD build .

Or using devtools:

devtools::build()

To check the package against CRAN rules:

devtools::check(cran = TRUE)

Tests

Tests use the testthat framework with vcr and webmockr for fixture-based mocking.

For full details on running tests, recording cassettes, and coverage, see the Testing Guide.

Documentation

Documentation is generated from roxygen2 comments. To build:

devtools::document()

Vignettes

Vignettes are precompiled because they require OpenAQ API authentication and cannot be built in a standard CRAN check environment. See vignettes/README.md for details on rebuilding vignettes from source.

Code Style

Code style is enforced using lintr. To check locally:

lintr::lint_package()