# Installation To install this package directly from git, you will first need the devtools and getPass packages if not already installed: ``` install.packages(c("devtools", "getPass")) ``` Then, the ASPREE package itself can be installed using the following command: ``` username <- "your_monash_username" devtools::install_git("https://gitlab.erc.monash.edu.au/aspree/aspree-r-package.git", credentials = git2r::cred_user_pass(username, getPass::getPass())) ``` You will be prompted for your Monash GitLab credentials before installation proceeds. Here's an example using the ASPREE library to retrieve ASPREE XT consent status: ``` library(aspree) library(dplyr) aspreeConsent <- aspreeDb("ASPREE Data Snapshot") %>% getXTConsent() ``` # 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.