A collection of R functions and scripts commonly used by the BIUM-MZ Core Facility and the Bioinformatics group at the IMBEI.
You can browse the package contents at https://imbeimainz.github.io/BIUMmisc/.
You can install the development version of BIUMmisc
from GitHub with:
library("remotes")
remotes::install_github("imbeimainz/BIUMmisc")
# this one installs also all the Suggested dependencies and builds the vignette
remotes::install_github("imbeimainz/BIUMmisc",
dependencies = TRUE,
build_vignettes = TRUE)
- Place your function(s) in an R script named in a way that makes it easy to guess what's inside.
- Use Roxygen to document your function(s). Some useful tags:
@title
,@description
,@details
,@param
,@return
,@author
,@examples
,@export
,@import
/@importFrom
. - If possible, add an example in the Roxygen preamble to show how to run each function.
- If possible, add one or more unit tests to check that the function(s) work as intended (using testthat).
- If your function uses functions defined in other packages, import the latter by adding
@importFrom package function
in the Roxygen preamble. Then document the package (e.g. usingdevtools::document()
) to regenerate the NAMESPACE file. It's also considered good practice to refer to these external functions withpackage::function
in the code, to avoid namespace clashes. - As far as possible, avoid hardcoding options (e.g., point sizes in plots, or other things that someone might want to change). Instead provide them as arguments to your function.
- Generally, it's good to keep functions small (and doing a single thing), for easier testing and increased modularity. As an example, if a function does both some calculations and plotting, it can often be better to split it up into two functions, each with a clearly defined scope.