Package 'washr'

Title: Publication Toolkit for Water, Sanitation and Hygiene (WASH) Data
Description: A toolkit to set up an R data package in a consistent structure. Automates tasks like tidy data export, data dictionary documentation, README and website creation, and citation management.
Authors: Mian Zhong [aut] (ORCID: <https://orcid.org/0009-0009-4546-7214>), Margaux Götschmann [aut] (ORCID: <https://orcid.org/0009-0002-2567-3343>), Colin Walder [aut] (ORCID: <https://orcid.org/0009-0006-0969-1954>), Lars Schöbitz [aut, cre] (ORCID: <https://orcid.org/0000-0003-2196-5015>), Global Health Engineering, ETH Zurich [cph]
Maintainer: Lars Schöbitz <[email protected]>
License: GPL (>= 3)
Version: 1.3.0.9000
Built: 2026-11-10 15:21:30 UTC
Source: https://github.com/openwashdata/washr

Help Index


Check whether the data package is ready for publication

Description

check_publication_readiness() walks through the publication workflow and reports, item by item, what is in place and what is missing. For every gap it names the step and the washr function that closes it, so a skipped step shows up here and not as an error in a later function. The function only reads the package. It writes nothing.

The items are the mechanically decidable part of the openwashdata review standard for the metadata, the data dictionary, the documentation and the check workflow of a package. Each item has a stable id, so a script or a review tool can pick the rows it needs.

Area id Passes when
metadata license License in DESCRIPTION is CC BY 4.0, the license of the standard
metadata description_complete Title, Description and Authors@R no longer hold the placeholder text of a new package
metadata citation_cff CITATION.cff is present
metadata citation_version the version in CITATION.cff equals Version in DESCRIPTION
metadata version_follows_data on a release version with a tag ⁠v<version>⁠, ⁠data/⁠, ⁠inst/extdata/⁠ and data-raw/dictionary.csv are unchanged since that tag
metadata citation_authors CITATION.cff and inst/CITATION carry real authors, not "Firstname Lastname"
metadata zenodo_json .zenodo.json is present and equals what DESCRIPTION gives now
metadata keywords DESCRIPTION carries X-schema.org-keywords; the detail says whether CITATION.cff agrees
metadata coverage DESCRIPTION carries X-schema.org-spatialCoverage and X-schema.org-temporalCoverage
metadata title_length Title has at most 65 characters
metadata publisher_ror the parent organisations of the publisher (Config/washr/parent-organizations) carry at least one ROR; not applicable when the profile names none
data data_present ⁠data/⁠ holds at least one .rda file that loads
data dictionary_present data-raw/dictionary.csv is present
data dictionary_coverage the dictionary covers every variable of every data object
data dictionary_descriptions no description is empty or a placeholder
data dictionary_schema the five washr columns first, in order, further named columns allowed, UTF-8 without a byte order mark, one class name per variable_type
docs roxygen_docs every data object has a help page in ⁠man/⁠
docs readme README.Rmd and the rendered README.md are present
docs rd_source at least one help page in ⁠man/⁠ carries a source
docs readme_extdata_links README.md links a .csv or .xlsx file under ⁠inst/extdata/⁠
docs readme_citation README.md names the DOI that CITATION.cff carries
docs vignettes_location no .Rmd or .qmd file sits directly in ⁠vignettes/⁠
docs pkgdown_config ⁠_pkgdown.yml⁠ is present
docs pkgdown_analytics ⁠_pkgdown.yml⁠ carries the analytics header
docs pkgdown_url url in ⁠_pkgdown.yml⁠ is the Pages URL, not the repository URL
docs pkgdown_funding ⁠_pkgdown.yml⁠ carries the funding text of the organisation
docs pkgdown_publisher the footer in ⁠_pkgdown.yml⁠ carries the publisher sentence of the organisation
docs pkgdown_washr_version the footer in ⁠_pkgdown.yml⁠ names the washr version that Config/washr/version records
docs pkgdown_brand the brand entry in ⁠_pkgdown.yml⁠ matches the organisation
docs pkgdown_llm_docs ⁠_pkgdown.yml⁠ does not switch off the llms.txt of the site (llm-docs: false)
docs site_jsonld pkgdown/assets/metadata.jsonld is present and equals the JSON-LD in the head of the pages (⁠pkgdown/templates/in-header.html⁠), both written by update_metadata()
docs docs_untracked git tracks no file under ⁠docs/⁠ while the pkgdown workflow deploys the site
tests check_workflow .github/workflows/R-CMD-check.yaml is present
tests check_workflow_dev every ⁠branches:⁠ list in that workflow includes dev
tests check_badge README.Rmd carries the R CMD check badge

An item that cannot be decided is reported as not applicable, with the reason: for example the version comparison when CITATION.cff is missing, or the ⁠docs/⁠ item when the package has no pkgdown workflow. Not applicable items never count against the package.

The version of a data package changes only when the data, or their meaning, change. version_follows_data compares the working tree, uncommitted and untracked files included, with the tag ⁠v<version>⁠ of the release the version names. An .rda file counts as changed only when the objects it holds differ, and an .xlsx file in ⁠inst/extdata/⁠ only when the .csv file of the same name changed as well, since both formats change their bytes when they are written again. The item is not applicable on a development version, without git, without the tag (also in a shallow clone that lacks it) or when the package is not the root of its git repository.

Usage

check_publication_readiness(path = ".", profile = NULL)

Arguments

path

Path to the root of the data package. Defaults to the working directory.

profile

A named list with what the organisation expects of its packages. With NULL, the default, the package is held to its own values: the ⁠Config/washr/⁠ fields in its DESCRIPTION that update_description() writes. A review tool passes the profile of the organisation instead. All entries are optional:

  • license: the license the package has to carry, "CC BY 4.0" by default, or "any" to accept every license that is set. A package of another organisation that is held to its own values gets "any".

  • analytics: "plausible" (the default) or "none". With "none" the analytics item is not applicable.

  • site_url_pattern: the Pages URL of a package, with ⁠<package>⁠ in place of the package name. Without it, any github.io URL passes.

  • funding_text: the funding sentence that ⁠_pkgdown.yml⁠ has to carry word for word. Without it, the funding item is not applicable.

  • publisher_text: the publisher sentence the footer has to carry word for word. Without it, the publisher item is not applicable.

  • keywords_required: keywords every package of the organisation has to carry.

  • brand: "none" when the organisation has no brand, or the name of its brand. Without it, the brand item is not applicable.

  • parent_organizations: the organisations above the publisher, in the form of Config/washr/parent-organizations (⁠Name <url>⁠ entries separated by semicolons). Without it, or with "none", the ROR item is not applicable.

Value

A data frame of class washr_readiness, invisibly, with one row per item and the columns id, area, check (the item in words), status ("pass", "fail" or "na" for not applicable), detail (what was found) and fix (the step that closes the gap). The attribute ready is TRUE when no item fails, washr_version holds the installed washr version, and package the name and version of the package that was checked. Printing the object shows the report again.

See Also

Before: every step of the workflow, up to update_citation() and setup_website(). Next: fix the items that fail and run it again, then release the package.

Other publishing functions: data_availability_statement(), setup_readme(), setup_website(), update_website(), use_brand()

Examples

## Not run: 
check_publication_readiness()

# Keep the result and work with the items that fail
readiness <- check_publication_readiness()
readiness[readiness$status == "fail", c("id", "detail", "fix")]
attr(readiness, "ready")

## End(Not run)

Draft the citation and data availability text for an article

Description

data_availability_statement() drafts the text that the authors of an article need once the data package has a DOI: the reference list entry in APA style, the data availability statement and the in-text citation. All three come from metadata the package already holds, so they are ready the moment the DOI is on file.

The sources are:

Part Source
authors Authors@R in DESCRIPTION, roles aut and cre, in their order (the same persons as CITATION.cff and .zenodo.json)
year date-released in CITATION.cff, else Date in DESCRIPTION
title, version, licence Package, Title, Version, License in DESCRIPTION
DOI doi in CITATION.cff, which update_citation() writes
repository the GitHub repository in the URL field of DESCRIPTION
website the url in ⁠_pkgdown.yml⁠, else the github.io entry of the URL field
download formats the CSV and Excel files in inst/extdata
withheld data Config/washr/withheld in DESCRIPTION

Usage

data_availability_statement(subject = "The data", clipboard = FALSE)

Arguments

subject

The opening words of the statement, which name the data the article uses. Defaults to "The data", which gives "The data supporting this study are openly available ...". Write it for the article, e.g., "The household survey data".

clipboard

Logical. Copy the reference entry and the statement to the clipboard as well? Defaults to FALSE. Needs the clipr package.

Details

The reference entry follows APA 7: authors as "Family, I. I.", with "&" before the last one, and with 21 or more authors the first 19, an ellipsis and the last author. An author without a family name is an organisation and keeps its full name. The entry ends with the repository URL ("Available at ..."). The in-text citation names one author, two authors joined by "&", or the first author followed by "et al." for three or more.

The statement names the licence, the package and its version, the DOI and the in-text citation. When the package has a website, a second sentence points to it for the CSV and Excel downloads found in inst/extdata. When some data was left out of the package, write one sentence that says what and why into DESCRIPTION, for example ⁠Config/washr/withheld: Household coordinates are not included, to protect the privacy of the respondents.⁠ The sentence closes the statement word for word.

The function stops when CITATION.cff carries no DOI yet: run update_citation() with the DOI of the Zenodo record first. Run it on the released version; a development version (such as ⁠1.0.0.9000⁠) gives a warning, because the text would name a version that is not archived.

Value

A named character vector of class washr_data_availability with the elements reference, statement and in_text. Printing it shows the three parts.

See Also

Before: update_citation() with the DOI of the Zenodo record.

Other publishing functions: check_publication_readiness(), setup_readme(), setup_website(), update_website(), use_brand()

Examples

## Not run: 
data_availability_statement()

# Name the data the article uses, and copy the text to the clipboard
data_availability_statement(subject = "The household survey data",
                            clipboard = TRUE)

## End(Not run)

Set up the R CMD check workflow for the data package

Description

setup_ci() writes the GitHub Actions workflow that runs ⁠R CMD check⁠ on every push and pull request to main and dev, on macOS, Windows and three versions of R on Linux. The openwashdata review standard requires this workflow with the dev trigger, so a package scaffolded with washr passes that part of the review floor by construction.

The workflow lands in .github/workflows/R-CMD-check.yaml and .github is added to .Rbuildignore. When README.Rmd exists with badge markers, the matching R CMD check badge is added between them (the README template from setup_readme() carries it already). An existing workflow file is kept as it is, so the function is safe to run again.

Usage

setup_ci()

Value

The path of the workflow file, invisibly.

See Also

Next: setup_rawdata(). The badge appears in the README written by setup_readme().

Other setup functions: setup_dictionary(), setup_rawdata(), setup_roxygen(), update_dictionary()

Examples

## Not run: 
setup_ci()

## End(Not run)

Create a dictionary file for tidy data sets

Description

setup_dictionary() generates a dictionary CSV file in the ⁠data/⁠ directory. The dictionary file contains information on the tidy data sets such as directory, file names, variable names, variable types, and descriptions. If tidy data exists, the dictionary is populated with relevant information; otherwise, it creates an empty dictionary CSV file.

Usage

setup_dictionary()

Value

The path of the dictionary file, invisibly. Error if raw data is not found or not in a package directory.

See Also

Before: setup_rawdata(). Next: setup_roxygen() once the descriptions in data-raw/dictionary.csv are written. When the data changes later, update_dictionary() brings the dictionary in line with it and keeps the descriptions.

Other setup functions: setup_ci(), setup_rawdata(), setup_roxygen(), update_dictionary()

Examples

## Not run: 
setup_rawdata()
# Go to data_processing.R, clean the raw data and export tidy data
setup_dictionary()

## End(Not run)

Create the data-raw directory with a data-processing.R template

Description

setup_rawdata() creates a directory for raw data and an example script named data_processing.R for importing, processing and exporting the tidy data. The export block of the script writes one usethis::use_data() line per dataset and then exports each dataset to inst/extdata as CSV and XLSX in one loop over the names, for a single dataset as well. Without datasets, the one dataset is named after the package.

Usage

setup_rawdata(datasets = NULL)

Arguments

datasets

Character vector of the names of the tidy data objects the script exports, such as c("trips", "trucks"). The default NULL names one dataset after the package. Each name has to be a syntactically valid R name (make.names(x) == x), because it becomes an object in the script; the function stops otherwise. ⁠data/⁠ is not read: the names are the objects the script is about to create.

Value

The path of the processing script, invisibly. The function creates the directory "data-raw" under the package directory.

See Also

Before: setup_ci(). Next: setup_dictionary() once the processing script has exported the tidy data with usethis::use_data().

Other setup functions: setup_ci(), setup_dictionary(), setup_roxygen(), update_dictionary()

Examples

## Not run: 
  setup_rawdata()
  # A package with two datasets
  setup_rawdata(datasets = c("trips", "trucks"))

## End(Not run)

Generate the README RMarkdown file

Description

setup_readme() uses the openwashdata README template to generate README files based on datasets retrieved from the ⁠data/⁠ directory. It helps in creating consistent and informative README documentation for your data packages. The repository links, the install line and the license come from DESCRIPTION, so run update_description() first.

The Citation section names the publisher with its website, states in plain text which version to cite with which DOI, links the authors page of the site and CITATION.cff, and names the source article of republished data from X-schema.org-isBasedOn. When the package names its site (the url of ⁠_pkgdown.yml⁠ or a site entry in the DESCRIPTION URL field), the section also links metadata.jsonld on the site, the schema.org metadata that update_metadata() writes, so the link reaches the llms.txt of the site. When use_brand() has installed the logo (man/figures/logo.png), the title line shows it, linked to the website of the organisation. The download links point at the release tag of the version in DESCRIPTION, and at the main branch for a development version. pkgdown builds the llms.txt of the site from the README, so this is also what AI tools read about the package.

The Data section has one section per data object: a preview of the first rows and the table of its variables from data-raw/dictionary.csv. Without datasets, every data object in ⁠data/⁠ gets a section, in alphabetical order. With several objects the introduction of the Data section names their number. The Example section, with has_example = TRUE, starts from the first object. An object without rows in the dictionary gets a warning, because its table of variables would be empty. The function stops when ⁠data/⁠ holds no data object, because every data section needs one.

Usage

setup_readme(force = FALSE, has_example = FALSE, datasets = NULL)

Arguments

force

Logical. If FALSE (the default), the function stops when a README.Rmd already exists. Set to TRUE to overwrite the existing file.

has_example

Logical. Should the README include an Example section with a commented ggplot2 scaffold for a first plot of the data? Defaults to FALSE. Pairs with the has_example argument of setup_website(), which adds the matching article to the site.

datasets

Character vector. The data objects in ⁠data/⁠ that get a section, in this order, such as c("trips", "trucks"). The default NULL takes every data object in ⁠data/⁠, alphabetically. A name that is not a data object in ⁠data/⁠ stops the run.

Value

The path of README.Rmd, invisibly.

See Also

Before: update_description(). Next: setup_website(), which builds the site from README.md.

Other publishing functions: check_publication_readiness(), data_availability_statement(), setup_website(), update_website(), use_brand()

Examples

## Not run: 
# Generate the README file after setting up the dictionary
setup_dictionary()
# Complete and save the dictionary CSV file with variable descriptions
setup_readme()
# With an Example section to fill with a first plot
setup_readme(has_example = TRUE)
# Sections for two of the data objects only
setup_readme(datasets = c("trips", "trucks"))

## End(Not run)

Set up roxygen documentation for all tidy data sets using the dictionary

Description

Creates or updates Roxygen documentation for all tidy data sets found in the dictionary file.

When first run, this function creates the Roxygen documentation with placeholders for the title and description field. The dictionary should include columns for directory, file name, variable name, variable type, and description. This function generates Roxygen comments with this information, facilitating consistent and thorough documentation for your data sets.

When re-run this function, this function updates only the variable description entries in the Roxygen documentation files within R/ directory. The title and description fields remain unchanged.

Usage

setup_roxygen()

Value

The paths of the documentation files inside "R/", invisibly, one per data set. Error if tidy data cannot be found.

See Also

Before: setup_dictionary(), or update_dictionary() after the data changed. Next: update_description().

Other setup functions: setup_ci(), setup_dictionary(), setup_rawdata(), update_dictionary()

Examples

## Not run: 
setup_dictionary()
# Once the dictionary is created, go to data-raw/dictionary.csv and complete the column description.
setup_roxygen()

## End(Not run)

Set up a pkgdown website for the data package

Description

setup_website() writes the openwashdata pkgdown configuration and builds the site from the package documentation and README.md. The configuration comes from the washr template, filled from DESCRIPTION: the Pages URL as the site URL, the repository link, the analytics header, the link to the website of the organisation in the navbar, the funding and the community blocks of the sidebar, the authors footer, the footer that names the washr version and the publisher, and a reference index with one entry per data object in ⁠data/⁠. The texts and links are the ⁠Config/washr/⁠ fields that update_description() writes (analytics-domain, funding, home, community, publisher); a field set to none leaves its block out. update_website() brings an existing file up to date.

The function is safe to re-run. An existing ⁠_pkgdown.yml⁠ is kept as it is and only the site is rebuilt, so hand edits and the brand wiring from use_brand() survive. The example article is created once.

By default the built ⁠docs/⁠ folder is tracked in git, which is how openwashdata packages publish their site from main. When the package deploys through the pkgdown GitHub Actions workflow instead (.github/workflows/pkgdown.yaml exists), ⁠docs/⁠ stays ignored.

Usage

setup_website(has_example = FALSE, track_docs = NULL)

Arguments

has_example

Logical. Should the pkgdown website include a vignette page for writing an example? Defaults to FALSE.

track_docs

Logical. Remove docs from .gitignore so the built site is committed? Defaults to TRUE unless a pkgdown workflow exists under ⁠.github/workflows/⁠.

Value

The path of ⁠_pkgdown.yml⁠, invisibly. Error if no README file is found.

See Also

Before: setup_readme(). Next: use_brand() for the brand, and update_citation() once the release has a DOI. update_website() updates an existing ⁠_pkgdown.yml⁠.

Other publishing functions: check_publication_readiness(), data_availability_statement(), setup_readme(), update_website(), use_brand()

Examples

## Not run: 
# Set up the pkgdown website including a vignette page
 setup_website(has_example = TRUE)

## End(Not run)

Update the citation file for the dataset.

Description

Create a citation *.cff file for the dataset from a given DOI (Digital Object Identifier). When a DOI is supplied, it adds the DOI badge to the README RMarkdown file (the Zenodo badge, or a generic DOI badge when Config/washr/doi-provider in DESCRIPTION names another provider) and re-builds the README.md and pkgdown website if they exist. Before a release exists, call it without arguments to generate the citation files without a DOI or badge.

The same run writes .zenodo.json through update_zenodo_json(), so the metadata Zenodo reads at release time comes from the same DESCRIPTION as the citation files.

Usage

update_citation(doi = NULL, build = TRUE, type = c("dataset", "software"))

Arguments

doi

DOI (Digital Object Identifier), e.g., 10.5281/zenodo.11185699. Defaults to NULL for the call before the release, in which case no DOI is recorded and no badge is added.

build

Logical. Rebuild README.md and the pkgdown site after the citation files change? Defaults to TRUE. Set to FALSE to regenerate the citation files alone, e.g., in scripts and tests.

type

The CFF type of the work: "dataset" (the default, a data package) or "software". Before 1.1.1 the file always said software, the cffr default. Zenodo's GitHub integration ignores this field; the resource type of a deposit comes from .zenodo.json, which always says dataset.

Details

When the data comes from a published article, list the article DOI in DESCRIPTION as X-schema.org-isBasedOn, e.g., ⁠X-schema.org-isBasedOn: https://doi.org/10.2166/wh.2026.173⁠. Separate several DOIs with commas. update_citation() looks up each DOI at doi.org and writes it as a references entry in CITATION.cff, with a message that asks users to cite both the data package and the article. inst/CITATION then holds both entries, so citation() prints both. The package itself stays the work cited by GitHub's "Cite this repository". A DOI that cannot be looked up keeps its entry from the existing CITATION.cff. Other references in CITATION.cff or inst/CITATION are dropped, because DESCRIPTION is their canonical source (#134).

Value

The paths of the three files written, CITATION.cff, inst/CITATION and .zenodo.json, invisibly.

See Also

Before: setup_website(). Run again with the DOI after the Zenodo release; update_metadata() then picks the DOI up. update_zenodo_json() for the Zenodo metadata file alone.

Other metadata functions: update_description(), update_metadata(), update_zenodo_json()

Examples

## Not run: 
  update_citation(doi = "10.5281/zenodo.11185699")
  # Regenerate the citation files without rebuilding README.md and the site
  update_citation(build = FALSE)

## End(Not run)

Update the DESCRIPTION file to conform with openwashdata standards

Description

This function updates the DESCRIPTION file of an R package to comply with openwashdata standards. It ensures that fields such as License, Language, Date, URL, and others are correctly specified. Date is written once and then kept; a release sets it through date. Existing URL and Config/Needs/website entries are preserved and merged with the openwashdata defaults. A CC BY 4.0 license is only set when the package does not have a license yet; an existing license is left untouched.

Usage

update_description(file = ".", github_user = NULL, date = NULL)

Arguments

file

Character. The file path to the DESCRIPTION file of the R package. Defaults to the current working directory.

github_user

Character. The URL of the GitHub user or organization that hosts the package, e.g., "https://github.com/yourorg". Defaults to the organisation of the repository already listed in URL, and to "https://github.com/openwashdata" when URL lists none.

date

The Date field for a release: "today", a Date, or a "YYYY-MM-DD" string; any other value stops the run. The default NULL keeps an existing date and writes today only when the field is absent, so a run that changes nothing about the data does not move the date of the package (#150).

Details

DESCRIPTION is where the other functions read the facts of the package: the GitHub organisation and the repository from URL, the license from License, the people from Authors@R. The values that DESCRIPTION has no standard field for are written as ⁠Config/washr/⁠ fields, and every other function reads them from there:

Field Used for openwashdata default
Config/washr/funding the funding sentence in the sidebar of the site the ETH Board Open Research Data Program
Config/washr/analytics-domain the Plausible analytics header of the site openwashdata.github.io
Config/washr/doi-provider the DOI badge of the README zenodo
Config/washr/zenodo-community the community in .zenodo.json openwashdata
Config/washr/brand-source the GitHub repository use_brand() copies from openwashdata/brand
Config/washr/publisher the publisher sentence in the footer of the site "Published by openwashdata, a project of Global Health Engineering at ETH Zurich." with links
Config/washr/home the website of the organisation: the navbar link, the line under the README badges, the publisher url in the metadata ⁠https://openwashdata.org⁠
Config/washr/catalog the data catalogue named in the metadata (includedInDataCatalog) the Data page of openwashdata.org
Config/washr/community the text of the community block in the sidebar of the site the openwashdata block with the catalogue and the newsletter
Config/washr/parent-organizations the organisations above the publisher in the metadata (parentOrganization), nearest first, as ⁠Name <url>⁠ entries separated by semicolons; a ⁠https://ror.org/⁠ URL becomes the ROR identifier Global Health Engineering, the Institute of Design, Materials and Fabrication and ETH Zurich, the last two with their ROR
Config/washr/version the washr version that last ran this function; also named in the footer of the site

A field that you edited is never overwritten, so a group other than openwashdata publishes with its own values by editing them. When the package moves to another organisation, whether github_user names it or URL was edited by hand, the fields that still hold the defaults of the old organisation follow; with github_user, the repository in URL is replaced as well. Set a field to none to switch its feature off. For a package under another GitHub organisation the funding, analytics, Zenodo community, brand, publisher, website, catalogue, community and parent organisations fields are written as none, because the openwashdata values would be wrong there. One more field is only ever written by hand: Config/washr/pages-domain, for a site that is not served from ⁠<organisation>.github.io⁠.

Value

The path of the DESCRIPTION file, invisibly. The fields are updated in the file.

See Also

Before: setup_roxygen(). Next: update_metadata() for the schema.org metadata, then setup_readme().

Other metadata functions: update_citation(), update_metadata(), update_zenodo_json()

Examples

## Not run: 
 # Update DESCRIPTION file in the current package
update_description()

 # Update DESCRIPTION file in a specific package
update_description(file = "path/to/your/package/DESCRIPTION")

 # Update DESCRIPTION file with a specific GitHub user
update_description(github_user = "https://github.com/yourusername")

## End(Not run)

Bring the dictionary in line with the tidy data

Description

update_dictionary() reads the data objects in ⁠data/⁠ again and updates data-raw/dictionary.csv to match them. Run it after the data changed: a variable was added, removed or renamed, its type changed, or a data object was added or removed.

What you wrote in the dictionary is kept. Rows are matched on file_name and variable_name, and a matched row keeps its description and the value of every other column, including columns you added yourself, such as unit or allowed_values. Only variable_type is refreshed from the data. A new variable gets a row with empty cells to fill in. The row of a variable that no longer exists is removed, and the function names it. A renamed variable or data object cannot be told from one removed and one added, so what you wrote in the removed rows is printed for you to copy into the new rows.

A dictionary in an older layout is brought to the washr layout first: an unnamed index column and unnamed empty columns from a spreadsheet are dropped, directory and file_name are derived from the data objects when the file lacks them or holds placeholders (a variable that several data objects carry gets one row per object), and a row whose variable no data object carries stops the run with the variable named.

The five washr columns come first, in order; every other column keeps its place after them. The rows follow the data: data objects in alphabetical order, variables in the order of the data object. When nothing differs, the file is left untouched, so the function is safe to run again.

Usage

update_dictionary()

Value

The path of the dictionary file, invisibly. Error if there is no dictionary yet, no tidy data, or the dictionary lacks the file_name or variable_name column.

See Also

Before: setup_dictionary(), which writes the dictionary the first time. Next: setup_roxygen(), which regenerates the variable table of the documentation from the dictionary.

Other setup functions: setup_ci(), setup_dictionary(), setup_rawdata(), setup_roxygen()

Examples

## Not run: 
setup_dictionary()
# Later, after data_processing.R exported changed data
update_dictionary()
setup_roxygen()

## End(Not run)

Generate and embed the schema.org metadata of the data package

Description

[Experimental]

update_metadata() derives a schema.org Dataset description from the canonical sources of the package and writes it as a JSON-LD block into the head of every pkgdown page, where dataset search engines read it. Nothing is hand edited: to change a value, change its source and run the function again. Running it twice produces no change. It ends by listing the fields it could not fill and where to fill them.

The sources are:

Field Source
name, description, version, datePublished, license Title, Description, Version, Date, License in DESCRIPTION
url the pkgdown site (a github.io entry in URL), else the repository
keywords X-schema.org-keywords in DESCRIPTION, comma separated
spatialCoverage, temporalCoverage X-schema.org-spatialCoverage and X-schema.org-temporalCoverage in DESCRIPTION
isBasedOn the source article DOIs in X-schema.org-isBasedOn in DESCRIPTION, comma separated
creator, maintainer, funder, publisher Authors@R roles aut/cre, cre, fnd, cph; ORCID from the comment field, and the ROR comment key of an organisation as its ⁠@id⁠. Without a cph, the publisher is the organisation with the website in Config/washr/home. The organisations in Config/washr/parent-organizations nest under the publisher as parentOrganization, a ⁠https://ror.org/⁠ URL as the ⁠@id⁠; the entries up to and including the publisher itself (same name, or the publisher name followed by a comma) are skipped
includedInDataCatalog the data catalogue of the organisation in Config/washr/catalog
identifier, sameAs the DOI in CITATION.cff, written by update_citation()
variableMeasured data-raw/dictionary.csv
distribution every file in inst/extdata that belongs to a dataset, one entry per file

The JSON-LD lands in ⁠pkgdown/templates/in-header.html⁠, which pkgdown picks up on the next site build. The file also keeps the in_header includes from ⁠_pkgdown.yml⁠ working. The same JSON-LD is also written to pkgdown/assets/metadata.jsonld, which pkgdown copies to the root of the site, so the metadata has its own address (⁠<site>/metadata.jsonld⁠) for tools that read files rather than page heads; the README links it. Each file is written only when its content changed. Neither is shipped in the package tarball.

Usage

update_metadata(quiet = FALSE)

Arguments

quiet

Logical. Suppress the messages and the report of blank fields. Defaults to FALSE, or to TRUE when options(washr.quiet = TRUE) is set.

Value

The Dataset description as a list, invisibly. The "blank" attribute names the fields that could not be filled and says where to fill them.

See Also

Before: update_description(), which writes the DESCRIPTION fields this reads. Next: setup_readme(). The DOI comes from update_citation().

Other metadata functions: update_citation(), update_description(), update_zenodo_json()

Examples

## Not run: 
update_metadata()

## End(Not run)

Bring an existing _pkgdown.yml in line with the washr template

Description

update_website() adds to an existing ⁠_pkgdown.yml⁠ what the washr template has gained since the file was written, and refreshes what washr owns: the footer with the washr version and the publisher sentence, the link to the website of the organisation in the navbar, the funding and the community blocks of the sidebar, and the Open Graph image when the brand is installed. Everything else is kept as it is: the reference index, hand edits, comments and the brand wiring of use_brand(). A file that is current is left untouched (#145).

The texts and links come from the ⁠Config/washr/⁠ fields in DESCRIPTION that update_description() writes (publisher, home, catalog, community, funding); a field set to none leaves its block out. The footer names the washr version that last ran update_description(), which also refreshes that line on its own.

Blocks written by hand are respected. A footer, a navbar or a sidebar that already carries a component of the same name keeps it, and the function adds only what is missing. The file is written only when the result parses as YAML.

Usage

update_website(build = FALSE)

Arguments

build

Logical. Rebuild the site with pkgdown::build_site() when the file changed? Defaults to FALSE.

Value

Invisibly, the names of the blocks that changed ("footer", "navbar", "sidebar", "opengraph"), or an empty vector when the file was current.

See Also

Before: setup_website(), which writes a new ⁠_pkgdown.yml⁠ from the template, and use_brand(), which installs the brand this reads for the Open Graph image. Next: check_publication_readiness().

Other publishing functions: check_publication_readiness(), data_availability_statement(), setup_readme(), setup_website(), use_brand()

Examples

## Not run: 
# After a washr update, bring the site configuration up to date
update_website()

# The same, and rebuild the site
update_website(build = TRUE)

## End(Not run)

Write the Zenodo metadata file of the data package

Description

update_zenodo_json() writes .zenodo.json at the package root. Zenodo reads this file when a GitHub release is archived and takes the metadata of the record from it: the resource type (Dataset), the community, the title, the description, the creators with their ORCID iDs, the license, the keywords and the version. Without the file, Zenodo files a data package as Software in no community, because its GitHub integration reads only a few fields of CITATION.cff.

Nothing in the file is hand edited: to change a value, change its source and run the function again. Running it twice produces no change. update_citation() calls it, so the citation files and .zenodo.json are written in one step and stay in line with each other.

The sources are:

Key Source
title, version Title, Version in DESCRIPTION
description Description in DESCRIPTION, followed by a link to the package website when the package has one
upload_type always dataset
creators Authors@R roles aut and cre; ORCID and affiliation from the comment field
license License in DESCRIPTION, as the identifier Zenodo uses (e.g., cc-by-4.0)
keywords X-schema.org-keywords in DESCRIPTION, comma separated
communities Config/washr/zenodo-community in DESCRIPTION: openwashdata for an openwashdata package, none for another organisation until it sets one
related_identifiers the repository from URL in DESCRIPTION, the package website, and the source article DOIs in X-schema.org-isBasedOn in DESCRIPTION

Usage

update_zenodo_json()

Details

Zenodo uses .zenodo.json in place of CITATION.cff for the record, and it reads the file from the release tag. Commit the file before you create the release, and run the function again whenever DESCRIPTION changes.

Set Config/washr/zenodo-community in DESCRIPTION to file the record in another community, to several (comma separated), or to none for no community.

The package website is the url in ⁠_pkgdown.yml⁠, or else the entry of the DESCRIPTION URL field on the pages domain (github.io unless Config/washr/pages-domain names another). When there is one, the description becomes HTML, which Zenodo renders: the Description field as the first paragraph and "Explore the data on a curated website" with the link as the second. The website is also written as a related identifier with the relation isDocumentedBy. Without a website the description is the Description field as it is.

The repository from the URL field is always written as a related identifier with the relation isSupplementTo, because any related identifier replaces the link to the release tag on GitHub that Zenodo adds by default. A source article is written with the relation isDerivedFrom.

When washr does not know the license, the file carries none. Zenodo then takes the license GitHub detects for the repository, and CC0 1.0 for a dataset when GitHub detects none.

Value

The path of .zenodo.json, invisibly.

See Also

Before: update_description(), which writes the DESCRIPTION fields this reads. update_citation() calls this function. Next: the GitHub release that Zenodo archives.

Other metadata functions: update_citation(), update_description(), update_metadata()

Examples

## Not run: 
update_zenodo_json()

## End(Not run)

Install or refresh the openwashdata brand in the active package

Description

use_brand() copies the openwashdata brand definition (⁠_brand.yml⁠) and the logo files it references from the central openwashdata/brand repository into the package root. Re-running the function refreshes an existing copy and reports which files changed, so consuming packages stay in sync with the central definition.

Brand values are never edited locally: change them in openwashdata/brand first and cut a release tag there, then refresh consumers with use_brand(). After a brand release the order is the Quarto extension, the website, then the data packages.

By default the brand is copied at the latest release tag of the brand repository, and the tag is recorded in DESCRIPTION as Config/washr/brand, so the package says which brand it carries. A second run with no new tag changes no file. The brand repository is the Config/washr/brand-source field that update_description() writes (openwashdata/brand for openwashdata packages); a group with its own brand names its repository there, and none means there is no brand to install.

The brand file and the logo directory are added to .Rbuildignore, so they stay out of the built package and ⁠R CMD check⁠ does not report them as non-standard top-level files.

Usage

use_brand(ref = NULL, pkgdown = TRUE, source = NULL)

Arguments

ref

Character. Git reference (branch or tag) of the brand repository to copy from. Defaults to the latest release tag. Pass "main" to try brand changes that are not released yet.

pkgdown

Logical. Should ⁠_pkgdown.yml⁠ be wired to use the brand via bslib? Defaults to TRUE.

source

Character. Advanced: an alternative source for the brand files, either a local directory or a URL prefix. When NULL (the default), the raw GitHub content of the brand repository at ref is used. Mainly useful for tests and offline work.

Details

The small logo of the brand becomes the package logo: it is copied to man/figures/logo.png, where pkgdown shows it beside the title of the home page, and added to the title line of README.Rmd, so GitHub shows it too (pkgdown shows one logo, not two). When the brand names a dark counterpart of that logo, it goes to pkgdown/assets/logo-dark.png, and the one rule written to pkgdown/extra.css shows it on the dark theme of the site.

With pkgdown = TRUE (the default), an existing ⁠_pkgdown.yml⁠ is pointed at the brand through bslib (template.bslib.brand), so the next pkgdown::build_site() renders the site with the brand fonts and colors, brand.yml is listed in Config/Needs/website so the pkgdown workflow installs it, and the Open Graph image is set to the social preview of the brand repository at the installed release (assets/social-preview.png), so a shared link to the site shows the image of the organisation. The wiring adds its lines to ⁠_pkgdown.yml⁠ and leaves the rest of the file, comments included, as it is. Only when the template block already carries other bslib settings, or is written on one line, is the file rewritten through the yaml package, which does not preserve comments. When no ⁠_pkgdown.yml⁠ exists, the wiring is skipped with a hint to run setup_website() first. Building the wired site requires the brand.yml package (bslib asks for it at build time); it is listed in Suggests and installed on demand.

Value

Invisibly, a character vector of the files written or updated (empty when everything was already current).

See Also

Before: setup_website(), which writes the ⁠_pkgdown.yml⁠ this wires. For branded PDF and Word reports that read the installed ⁠_brand.yml⁠, the openwashdata Quarto extension quarto-owd.

Other publishing functions: check_publication_readiness(), data_availability_statement(), setup_readme(), setup_website(), update_website()

Examples

## Not run: 
# Install the brand and wire the pkgdown site
use_brand()

# Refresh later, without touching _pkgdown.yml
use_brand(pkgdown = FALSE)

## End(Not run)