| 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, cre] (ORCID: <https://orcid.org/0009-0006-0969-1954>), Lars Schöbitz [aut] (ORCID: <https://orcid.org/0000-0003-2196-5015>), Global Health Engineering, ETH Zurich [cph] |
| Maintainer: | Colin Walder <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.0.1 |
| Built: | 2026-05-26 07:04:45 UTC |
| Source: | https://github.com/openwashdata/washr |
Add contributors to the creators metadata file
add_creator(name = "", email = "", affiliation = "Openwashdata")add_creator(name = "", email = "", affiliation = "Openwashdata")
name |
Name of the contributor |
email |
Email ID of the contributor |
affiliation |
Affiliation (Institute/organisation of the contributor) |
NULL, Errors handled within the function
## Not run: add_creator("Jane Doe", 'janedoeatuniversity.org', affiliation = "University") ## End(Not run)## Not run: add_creator("Jane Doe", 'janedoeatuniversity.org', affiliation = "University") ## End(Not run)
Creates the data/metadata directory with the acess, attributes, biblio and creators metadata files. If the directory already exists, the user is prompted to overwrite the existing files.
add_metadata()add_metadata()
NULL. Error message if the metadata folder already exists and user declines to create new metadata files.
## Not run: add_metadata() ## End(Not run)## Not run: add_metadata() ## End(Not run)
Fill in the dictionary file based on the tidy data information
fill_dictionary(dict_path, data_dir)fill_dictionary(dict_path, data_dir)
dict_path |
Path to the dictionary csvfile. |
data_dir |
Path to the directory of the tidy R data objects. Defaults to data/ |
A tibble data frame of dataset dictionary with an empty description column to be written.
## Not run: update_dictionary(dict_path = "data-raw/my-dictionary.csv", data = "data/") ## End(Not run)## Not run: update_dictionary(dict_path = "data-raw/my-dictionary.csv", data = "data/") ## End(Not run)
This function follows a standard JSON-LD template and autopopulates it with metadata from the dataset. The function checks for appropriate files being available before executing. The JSON-LD document is saved to the metadata folder.
generate_jsonld()generate_jsonld()
NULL. Error messages are displayed if dictionary or metadata files are not found.
## Not run: generate_jsonld() ## End(Not run)## Not run: generate_jsonld() ## End(Not run)
This function takes a CSV table with columns variable_name and description as input,
optionally filters it by variable_name, and outputs roxygen2 documentation for \describe and \item.
generate_roxygen_docs(input_file_path, output_file_path, df_name = NULL)generate_roxygen_docs(input_file_path, output_file_path, df_name = NULL)
input_file_path |
Path to the input CSV file. |
output_file_path |
Path to the output file that will contain the roxygen2 documentation. |
df_name |
Optional name of the variable to filter the input dataframe by. Default is NULL. |
Character string of a generated roxygen documentation.
## Not run: # Generate roxygen2 documentation from example.csv generate_roxygen_docs("example.csv", "output.R") # Generate roxygen2 documentation from example.csv for a specific variable name generate_roxygen_docs("example.csv", "output.R", df_name = "specific_variable") ## End(Not run)## Not run: # Generate roxygen2 documentation from example.csv generate_roxygen_docs("example.csv", "output.R") # Generate roxygen2 documentation from example.csv for a specific variable name generate_roxygen_docs("example.csv", "output.R", df_name = "specific_variable") ## End(Not run)
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.
setup_dictionary()setup_dictionary()
NULL. Error if raw data is not found or not in a package directory.
## Not run: setup_rawdata() # Go to data_processing.R, clean the raw data and export tidy data setup_dictionary() ## End(Not run)## Not run: setup_rawdata() # Go to data_processing.R, clean the raw data and export tidy data setup_dictionary() ## End(Not run)
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 template assumes that the dataset name is the same as the data package name.
setup_rawdata()setup_rawdata()
NULL. This function will create a directory "data-raw" under the package directory.
## Not run: setup_rawdata() ## End(Not run)## Not run: setup_rawdata() ## End(Not run)
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.
setup_readme()setup_readme()
NULL. This function creates a README.Rmd under the package directory.
## 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() ## End(Not run)## 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() ## End(Not run)
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.
setup_roxygen()setup_roxygen()
NULL. This function creates documentation files inside "R/". Error if tidy data cannot be found.
## 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)## 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)
setup_website() uses the openwashdata pkgdown template to create a website for the data package
based on its README.md file. The website provides a structured and visually appealing presentation
of the package's documentation.
setup_website(has_example = FALSE)setup_website(has_example = FALSE)
has_example |
Logical. Should the pkgdown website include a vignette page for writing an example? Defaults to FALSE. |
NULL. Error if no README file is found.
## Not run: # Set up the pkgdown website including a vignette page setup_website(has_example = TRUE) ## End(Not run)## Not run: # Set up the pkgdown website including a vignette page setup_website(has_example = TRUE) ## End(Not run)
This function updates the access metadata file with the links to the downloadable data files
in xlsx and csv format. Redirects to the github repo raw download links. Meant to be a util function for
the update_metadata function.
update_access()update_access()
NULL.
## Not run: update_access() ## End(Not run)## Not run: update_access() ## End(Not run)
Updates the attributes file in the metadata folder with data from the dictionary file in the data-raw folder. This file is esentially a copy of the dictionary file. If the dictionary file does not exist, the user is asked to create it first. Always overwrites existing attributes file with the latest dictionary file.
update_attributes()update_attributes()
NULL. Error if dictionary file is not found.
## Not run: update_attributes() ## End(Not run)## Not run: update_attributes() ## End(Not run)
This function updates the biblio metadata file with the values from the DESCRIPTION file, along with some standard templated values for funder, license, etc.
update_biblio()update_biblio()
NULL. Throws an error if DESCRIPTION does not exist.
## Not run: update_biblio() ## End(Not run)## Not run: update_biblio() ## End(Not run)
Create a citation *.cff file for the released dataset from a given DOI(Digital Object Identifier). It adds the DOI badge to the README RMarkdown file and re-build the README.md and pkgdown website if exists.
update_citation(doi)update_citation(doi)
doi |
DOI(Digital Object Identifier), e.g., 10.5281/zenodo.11185699 |
NULL. A citation .cff file is written under the root directory.
## Not run: update_citation(doi = "10.5281/zenodo.11185699") ## End(Not run)## Not run: update_citation(doi = "10.5281/zenodo.11185699") ## End(Not run)
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.
update_description( file = ".", github_user = "https://github.com/openwashdata/" )update_description( file = ".", github_user = "https://github.com/openwashdata/" )
file |
Character. The file path to the DESCRIPTION file of the R package. Defaults to the current working directory. |
github_user |
Character. The URL path to the GitHub user or organization that hosts the current package. Defaults to "https://github.com/openwashdata". |
NULL. Update fields directly in DESCRIPTION file.
## 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)## 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)
This function updates the metadata google sheet with the values from available metadata. Github username is required to update the maintainer field.
update_gsheet_metadata(github_profile = "")update_gsheet_metadata(github_profile = "")
github_profile |
Github username of the maintainer |
NULL. Errors if metadata does not exist
## Not run: update_gsheet_metadata("githubusername") ## End(Not run)## Not run: update_gsheet_metadata("githubusername") ## End(Not run)
This function updates all metadata files simultaneously by calling helper functions. Ideally, this function is used rather than individual helpers.
update_metadata()update_metadata()
NULL. Error handling is done in the helper functions.
## Not run: update_metadata() ## End(Not run)## Not run: update_metadata() ## End(Not run)