GithubHelp home page GithubHelp logo

growthcharts / nlreferences Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 998 KB

Growth References for Children living in The Netherlands

Home Page: https://growthcharts.org/nlreferences/

R 100.00%
growth-curves netherlands rif-format

nlreferences's Introduction

nlreferences

R-CMD-check R-CMD-check

The nlreferences package provides Dutch reference values.

Installation

You can install the development version from GitHub with:

# 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.

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.

refs <- c("nl_1997_wst_male_", "nl_1997_wst_female_")

Next you need your data organized into “long format”. A minimal example is

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
#>    age    sex  y
#> 1  0.5   male 42
#> 2 10.0   <NA> 60
#> 3 17.4 female 70
#> 4 14.3 female NA
#> 5   NA   male 70

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.

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.

data
#>    age    sex  y                 ref    z
#> 1  0.5   male 42   nl_1997_wst_male_ 0.00
#> 2 10.0   <NA> 60                <NA>   NA
#> 3 17.4 female 70 nl_1997_wst_female_ 0.15
#> 4 14.3 female NA nl_1997_wst_female_   NA
#> 5   NA   male 70   nl_1997_wst_male_   NA

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.