{"id":14066365,"url":"https://github.com/poissonconsulting/chktemplate","last_synced_at":"2025-10-08T09:51:21.068Z","repository":{"id":191677937,"uuid":"288823998","full_name":"poissonconsulting/chktemplate","owner":"poissonconsulting","description":"An R package to work with excel templates for data upload","archived":false,"fork":false,"pushed_at":"2025-01-20T22:19:07.000Z","size":1612,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-01T18:42:58.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://poissonconsulting.github.io/chktemplate/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/poissonconsulting.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-19T19:53:57.000Z","updated_at":"2025-01-20T22:17:18.000Z","dependencies_parsed_at":"2024-02-19T18:22:31.190Z","dependency_job_id":"f4e2a08f-c198-482b-9702-8dc455ef1567","html_url":"https://github.com/poissonconsulting/chktemplate","commit_stats":null,"previous_names":["poissonconsulting/chktemplate"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Fchktemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Fchktemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Fchktemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Fchktemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poissonconsulting","download_url":"https://codeload.github.com/poissonconsulting/chktemplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245862222,"owners_count":20684645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:05:03.862Z","updated_at":"2025-10-08T09:51:16.029Z","avatar_url":"https://github.com/poissonconsulting.png","language":"R","readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# chktemplate\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![R-CMD-check](https://github.com/poissonconsulting/chktemplate/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/chktemplate/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/chktemplate/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/chktemplate)\n\u003c!-- badges: end --\u003e\n\nWork with data template by turning them into a human-readable format and confirm the data follows all the requirements.\n\n## Installation\n\nYou can install the development version from [GitHub](https://github.com/poissonconsulting/chktemplate) with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"poissonconsulting/chktemplate\")\n```\n\n## Demonstration\n\n```{r}\nlibrary(chktemplate)\n```\n\n### Convert Template to be Human Readable\n\nThe templates need to be written in code but this is not very readable for a user. \nUse the `template_human()` function to convert the template into a human readable form. \n\n```{r}\n# subset the first four columns so example fits on page\n# code version of the template\ndemo_template_fish_exploit$outing[1:4]\n# human readable version of the template\ntemplate_human(demo_template_fish_exploit$outing[1:4])\n```\n\n### Check Data Against Template Requirements \n\nPass data and the template to `check_data_format()` to ensure the data follows all the rules and requirements of the template. \nIt can check whether all columns are supplied, the type of the column, the range of values, the primary key, uniqueness of the column, and joins between tables.\n\n```{r}\nouting \u003c- data.frame(\n  outing_id = c(1L, 2L, 3L),\n  site_name = c(\"Pretty Bay\", \"Pretty Bay\", \"Pretty Bay\"),\n  year = c(2010, 2010, 2010),\n  month = c(07, 07, 07),\n  day = c(15, 16, 17),\n  hour_start = c(9L, 11L, 8L),\n  minute_start = c(0, 0, 0),\n  guide = c(\"JT\", \"JT\", \"JT\"),\n  rod_count = c(2, 3, 2),\n  comment = c(NA_character_, NA_character_, NA_character_)\n)\n\ndata \u003c- check_data_format(\n  outing = outing,\n  template = demo_template_fish_exploit\n)\n```\n\nThe `complete` argument checks if all tables are present.\n\n```{r}\nsite \u003c- data.frame(\n  site_name = c(\"Pretty Bay\", \"Ugly Bay\", \"Green Bay\")\n)\n\nouting \u003c- data.frame(\n  outing_id = c(1L, 2L, 3L),\n  site_name = c(\"Pretty Bay\", \"Pretty Bay\", \"Pretty Bay\"),\n  year = c(2010, 2010, 2010),\n  month = c(7, 7, 7),\n  day = c(15, 16, 17),\n  hour_start = c(9L, 11L, 8L),\n  minute_start = c(0, 0, 0),\n  guide = c(\"JT\", \"JT\", \"JT\"),\n  rod_count = c(2, 3, 2),\n  comment = c(NA_character_, NA_character_, NA_character_)\n)\n\ncapture \u003c- data.frame(\n  outing_id = c(1L, 2L, 3L),\n  guide = c(\"JT\", \"JT\", \"JT\"),\n  hour = c(7L, 8L, 7L),\n  minute = c(0L, 30L, 45L),\n  easting = c(1031941, 1031971, 1031944),\n  northing = c(892421, 892451, 892429),\n  species = c(\"BT\", \"CT\", \"CT\"),\n  forklength_mm = c(100, 700, 300),\n  weight_kg = c(0.5, 10, 4),\n  tbartag_number1 = c(78, 91, 82),\n  tbartag_number2 = c(14, 18, 21),\n  released = c(\"yes\", \"no\", \"no\")\n)\n\nrecapture \u003c- data.frame(\n  year = c(2009, 2009),\n  month = c(10, 10),\n  day = c(14, 15),\n  angler = c(\"Dave John\", \"John Smith\"),\n  contact = c(\"250-637-9999\", \"250-557-1414\"),\n  tbartag_number1 = c(92, 57),\n  tbartag_number2 = c(10, 12)\n)\n\ndata \u003c- check_data_format(\n  site = site,\n  outing = outing,\n  capture = capture,\n  recapture = recapture,\n  template = demo_template_fish_exploit,\n  complete = TRUE\n)\n```\n\nJoins are only checked if `join` is set to `TRUE`.\n\n```{r}\nsite \u003c- data.frame(\n  site_name = c(\"Pretty Bay\", \"Ugly Bay\", \"Green Bay\")\n)\n\nouting \u003c- data.frame(\n  outing_id = c(1L, 2L, 3L),\n  site_name = c(\"Pretty Bay\", \"Pretty Bay\", \"Pretty Bay\"),\n  year = c(2010, 2010, 2010),\n  month = c(7, 7, 7),\n  day = c(15, 16, 17),\n  hour_start = c(9L, 11L, 8L),\n  minute_start = c(0, 0, 0),\n  guide = c(\"JT\", \"JT\", \"JT\"),\n  rod_count = c(2, 3, 2),\n  comment = c(NA_character_, NA_character_, NA_character_)\n)\n\ncapture \u003c- data.frame(\n  outing_id = c(1L, 2L, 3L),\n  guide = c(\"JT\", \"JT\", \"JT\"),\n  hour = c(7L, 8L, 7L),\n  minute = c(0L, 30L, 45L),\n  easting = c(1031941, 1031971, 1031944),\n  northing = c(892421, 892451, 892429),\n  species = c(\"BT\", \"CT\", \"CT\"),\n  forklength_mm = c(100, 700, 300),\n  weight_kg = c(0.5, 10, 4),\n  tbartag_number1 = c(78, 91, 82),\n  tbartag_number2 = c(14, 18, 21),\n  released = c(\"yes\", \"no\", \"no\")\n)\n\nrecapture \u003c- data.frame(\n  year = c(2009, 2009),\n  month = c(10, 10),\n  day = c(14, 15),\n  angler = c(\"Dave John\", \"John Smith\"),\n  contact = c(\"250-637-9999\", \"250-557-1414\"),\n  tbartag_number1 = c(92, 57),\n  tbartag_number2 = c(10, 12)\n)\n\ndata \u003c- check_data_format(\n  site = site,\n  outing = outing,\n  capture = capture,\n  recapture = recapture,\n  template = demo_template_fish_exploit,\n  complete = TRUE,\n  join = TRUE\n)\n```\n\n## Template Requirements\n\nIn the templates the first column needs to be the name column which is a special column.\nThe name column sets out the rules for the template.\nNo other column can be called name.\n\nDescription of each row:\n\n- name: column names\n- example: sample value, optional\n- description: written description of the column\n- chk: range, type, missing value and set checks, see [chk::chk_values](https://poissonconsulting.github.io/chk/reference/check_values.html) for how values are checked \n- pkey: primary key, set values as `TRUE`, can be a combination of columns\n- unique: column has to be unique, set values as `TRUE`, optional\n- join1: place parent table name in the variable(s) that should be the `by` argument of join, optional\n  - a join row can only join to one table, to join to multiple tables add more join rows like join2, join3, etc. \n  - Check `chktemplate::demo_template_count` template for an example of a table with multiple join rows.\n\n## Code of Conduct\n\nPlease note that the `chktemplate` project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). \nBy contributing to this project, you agree to abide by its terms.\n","funding_links":[],"categories":["R"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoissonconsulting%2Fchktemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoissonconsulting%2Fchktemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoissonconsulting%2Fchktemplate/lists"}