|
| 1 | +# betydata Style Guide |
| 2 | + |
| 3 | +This guide documents the coding and data conventions for the `betydata` package. |
| 4 | + |
| 5 | +## R Code |
| 6 | + |
| 7 | +- **Pipe operator:** Use the native pipe `|>`, not `%>%`. |
| 8 | +- **Data frames:** Use `tibble::tibble()`, not `data.frame()`. |
| 9 | +- **Grouped operations:** Use `.by = c(col1, col2)` argument, not `group_by() |> ... |> ungroup()`. |
| 10 | +- **Early returns** over nested `if/else` blocks. |
| 11 | +- **Package-qualified calls** in package code: `dplyr::filter()`, not `filter()` after `library(dplyr)`. |
| 12 | + |
| 13 | +## Documentation |
| 14 | + |
| 15 | +- **Roxygen2** with markdown enabled (`Roxygen: list(markdown = TRUE)` in DESCRIPTION). |
| 16 | +- **Tags:** `@param`, `@return`, `@export`, `@author`, `@examples`. |
| 17 | +- **Title:** Short, one line, no trailing period. |
| 18 | +- **Description:** Second paragraph after a blank `#'` line. |
| 19 | +- Backtick-wrap code references in roxygen and vignettes. |
| 20 | + |
| 21 | +## Data Conventions |
| 22 | + |
| 23 | +- The primary table is `traitsview` -- a denormalized view combining traits and yields. |
| 24 | +- Source CSVs live in `data-raw/csv/` (version controlled, human-editable). |
| 25 | +- Built `.rda` files live in `data/` (generated by `data-raw/make-data.R`). |
| 26 | +- `checked = -1` records are excluded. `checked = NA` is converted to `checked = 0` during build. |
| 27 | +- Only public data (`access_level == 4`) is included. |
| 28 | + |
| 29 | +## Testing |
| 30 | + |
| 31 | +- Use `testthat` edition 3 (`Config/testthat/edition: 3` in DESCRIPTION). |
| 32 | +- Test files go in `tests/testthat/` with naming pattern `test-*.R`. |
| 33 | + |
| 34 | +## Version Control |
| 35 | + |
| 36 | +- Update `NEWS.md` for user visible changes. |
| 37 | +- Update `CITATION.cff` for non-trivial contributions (add yourself to `authors:`). |
| 38 | +- Keep commits focused -- one logical change per commit. |
| 39 | + |
| 40 | +## Data Corrections |
| 41 | + |
| 42 | +- To report errors: file a github issue using the "Data correction" template. |
| 43 | +- To submit fixes: edit the relevant CSV in `data-raw/csv/`, rebuild with `source("data-raw/make-data.R")`, and open a PR. |
0 commit comments