Commit 7d0857c1 authored by Jason Rigby's avatar Jason Rigby
Browse files

describe the development process

parent 4354d473
......@@ -11,3 +11,46 @@ devtools::install_git("https://gitlab.erc.monash.edu.au/aspree/aspree-r-package.
getPass::getPass()))
```
You will be prompted for your Monash GitLab credentials before installation proceeds.
# Development
Recommended reading: [the devtools cheatsheet](https://www.rstudio.com/wp-content/uploads/2015/03/devtools-cheatsheet.pdf)
## Dependencies
Package dependencies must be declared in the [DESCRIPTION](DESCRIPTION) file. Use the `devtools::use_package()` function to add these automatically.
## Documentation
Use the `roxygen` to document every function that needs to be visible to the end-user. Roxygen documentation can be provided by writing specially formatted comments above each function. An example from [the devtools cheatsheet](https://www.rstudio.com/wp-content/uploads/2015/03/devtools-cheatsheet.pdf):
```
#' Add together two numbers.
#'
#' @param x A number.
#' @param y A number.
#' @return The sum of \code{x} and \code{y}.
#' @examples
#' add(1, 1)
#' @export
add <- function(x, y) {
x + y
}
```
The documentation should describe at least
* What the function does
* Each function parameter
* The data returned
If the function needs to be visible to the end user, it should also tag the function with `@export`.
Once the functions are written, tested and documented, `devtools::document()` should be run. This will regenerate `NAMESPACE` and the markdown documents in the `man` directory appropriately.
## Testing and quality control
All functions should be appropriately unit tested, ideally using the automated test framework `testthat`. More detail information regarding tests can be found in the [tests/testthat](tests/testthat) subdirectory.
Tests should be written in a way that:
* will detect when errors in dependent functions or the underlying data arises, e.g. most functions that return ASPREE data will have 19,114 rows (one per participant)
* tests the behaviour when both valid and invalid data is provided, e.g. `sqrt(x)` should not be defined if a negative input is given
* never has an external dependency, e.g. pre-canned (fake) data should be provided to simulate database access
All changes should be proposed via GitLab merge requests and reviewed prior to acceptance. [Git `tags`](https://git-scm.com/book/en/v2/Git-Basics-Tagging) should be used to mark major releases to allow for reproducible analysis. Insofar as practical, git commits merged into the master branch should be squashed into units that sensibly describe their net effect.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment