Skip to content

Implement the exported functions #6

Description

@larnsce

Goal

The exported function set. Imports: tibble and utils. jsonlite, desc, cffr, gh and writexl live in Suggests or Config/Needs/harvest because only data-raw/ and the tests use them. No tidyverse package in Imports.

Rewritten 2026-09-04 per dev/decisions-2026-09.md. Start from R/owd_accessors.R, R/owd_search.R, R/owd_install.R, R/catalog.R and R/zzz.R on the closed PR #15 branch, minus the refresh and cache code.

Functions

  • owd_packages(published = NULL): the packages tibble; TRUE keeps published packages, FALSE the rest, NULL all
  • owd_datasets(pkg = NULL): datasets tibble, optionally filtered by package
  • owd_variables(pkg = NULL, dataset = NULL): variables tibble
  • owd_search(query, fields = c("title", "description", "variable_name", "dataset_name")): case-insensitive regex over a prebuilt flat index; returns pkg_name, match_type (package, dataset, variable), dataset_name, field, text
  • owd_install(pkg = NULL, ...): install.packages(pkg, repos = c("https://openwashdata.r-universe.dev", "https://cloud.r-project.org"), ...); pkg = NULL installs all published packages after an interactive confirmation showing the count and errors in non-interactive sessions

The catalog is the internal owd_catalog object from R/sysdata.rda, read through one internal accessor so the tables can only come from one place.

Attach behaviour

library(owdata) attaches nothing else. .onAttach() prints one packageStartupMessage(): "owdata catalog: 30 published packages, 48 datasets, 2676 variables (harvested 2026-09-08). Try owd_search(), owd_packages(), owd_install()." The harvest date is the staleness signal; there is no refresh function and no cache.

Acceptance criteria

  • Roxygen with examples for every export; the column reference for each table lives in the roxygen of its accessor
  • devtools::check() clean
  • A behavioural test per export; every expect_error() names its message
  • owd_search("groundwater") and owd_search("sanitation") return sensible hits

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions