-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
90 lines (64 loc) · 3.17 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# nlreferences
<!-- badges: start -->
[![R-CMD-check](https://github.com/growthcharts/nlreferences/workflows/R-CMD-check/badge.svg)](https://github.com/growthcharts/nlreferences/actions)
[![R-CMD-check](https://github.com/growthcharts/nlreferences/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/growthcharts/nlreferences/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->
The nlreferences package provides Dutch reference values.
## Installation
You can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("growthcharts/nlreferences")
```
## Example
Suppose you want to calculate Z-scores for waist circumference for Dutch boys and girls using the references published in Fredriks AM et al (2005).
The calculation requires two R packages: `nlreferences` (with the reference data) and `centile` (with the calculation method). Install both. You need to do this only once.
```{r eval=FALSE}
install.packages("remotes")
remotes::install_github("growthcharts/nlreferences")
remotes::install_github("growthcharts/centile")
```
The raw reference coordinates for boys and girls can be found in the `nlreferences` package as files `data-raw/data/nl1997/nl_1997_wst_male_.txt` and `data-raw/data/nl1997/nl_1997_wst_female_.txt`. See <https://github.com/growthcharts/nlreferences/tree/master/data-raw/data/nl1997>. To calculate Z-score for waist circumference, you need their file names without the path and extension.
```{r}
refs <- c("nl_1997_wst_male_", "nl_1997_wst_female_")
```
Next you need your data organized into "long format". A minimal example is
```{r}
data <- data.frame(
age = c(0.5, 10, 17.411, 14.328, NA),
sex = c("male", NA, "female", "female", "male"),
y = c(42.037, 60, 70, NA, 70)
)
data
```
Load the packages, and the run the `y2z()` function. Specify for each record the reference that you want to use, and convert each measurement `y` into a Z-score `z`.
```{r}
library(centile)
library(nlreferences)
data$ref <- ifelse(data$sex == "male", refs[1], refs[2])
data$z <- y2z(y = data$y, x = data$age, refcode = data$ref, pkg = "nlreferences")
```
And presto, your data with two extra columns `ref` and `z`.
```{r}
data
```
Tips:
- Column `z` will be `NA` when it cannot be calculated. Add argument `verbose = TRUE` to generate warnings;
- Use `y2p()` for conversion into percentiles;
- Use `z2y()` to convert Z-scores back into the original measurement scale;
- Use `tidyr::pivot_longer()` to convert wide to long organisation;
- When you have multiple measurements (e.g. also height and weight), add more rows to `data`, and specify the desired reference name in each row.
## Literature
- Fredriks AM, van Buuren S, Fekkes M, Verloove-Vanhorick SP & Wit JM (2005) Are age references for waist circumference, hip circumference and waist-hip ratio in Dutch children useful in clinical practice? European Journal of Pediatrics, 164, 216-222.