The clinicalr package is a collection of R functions to perform (basic) clinical calculations in medical research. User documentation can be found on GitHub.io.
Help and pull requests are more than welcome.
- Anthropometry
- Body mass index (BMI, Quetelet index).
- Body surface area (BSA).
- Ideal body weight (IBW).
- Mean arterial blood pressure (MAP).
- Pulse pressure.
- Cardiology
- Corrected QT interval (QTc).
- Electrolytes
- Albumin-adjusted calcium.
- Glucose-adjusted sodium.
- Infectiology
- CURB-65 community-acquired pneumonia severity score.
- qSOFA score for sepsis.
- Metabolism
- Presence of the metabolic syndrome.
- Nephrology
- Estimate glomerular filtration rate based on creatinine clearance.
Reliable
- Explicit units for output
- Numeric output of a function will have a specified unit attribute (if applicable) using the units package.
- Fail-fast without assumptions
- If certain conditions are not explicitly provided, err on the side of caution (e.g. a fasting state has to be provided in order for a glucose to be considered a fasting glucose). If
NA
values are provided, functions will returnNA
unless otherwise specified.
- If certain conditions are not explicitly provided, err on the side of caution (e.g. a fasting state has to be provided in order for a glucose to be considered a fasting glucose). If
- Explicit references and caveats
- Every function will have references and a section on caveats. (However, despite our best efforts of quality control, the functions are provided as-is, without any guarantees, and users would be wise to check the output for quality and accuracy in their use case.)
Practical
- Input using units by expected use case
- Units used in the functions can be inconsistent (m versus cm, s versus ms) on purpose to best suit the most common usage of certain formulae.
- Single entry functions if possible
- If multiple methods or formulae are known for the same phenomenon (e.g. body surface are), a single function is provided and the specific method can be specified as an argument. A default method is specified, if possible. This approach is not used if the parameters for functions differ.
If applicable, functions will return numeric values with a unit attribute using the units package. The idea is to be as explicit as possible to the end user about the generated data. However, the unit attributes may sometimes be bothersome. Use units::drop_units(x)
to drop the unit attribute. Load the ggforce package (an extension of ggplot) if you want to incorporate the unit attribute in the scales of a ggplot figure (see ggforce reference page Position scales for units data).
Clinicalr is not (yet) available on CRAN. Install devtools. Then use devtools to install clinicalr directly from GitHub using the remotes package.
install.packages("remotes")
remotes::install_github("ls31/clinicalr")
remotes::install_github("lc31/clinicalr")
- effective osmolality?
- anion gap?
- total body water?
- fractional excretion of sodium?
- transtubular potassium excretion?
- free water deficit?
- A-a gradient?
- creatinine clearance (using urine)?
- Framingham?
- full SOFA score?
- Calvert formula (AUC) for carboplatin?