childsds
childsds copied to clipboard
Calculation of standard deviation scores adduced from different growth standards (WHO, US, UK, Germany, Italy, China, etc). Therefore, the calculation of SDS-values for different measures like BMI, we...
- I moved the repository to Bitbucket for personal reasons.
- childsds
** List of available references/LMS charts
- you find a list of available reference tables by region and by item [[https://github.com/mvogel78/childsds/wiki][here]]. ** Installation
- version 0.6.4 from cran via ~install.packages()~ or the respective menu ** Basic use *** Transformation into sds #+BEGIN_SRC R :session :exports both :results output library(childsds)
generate example data
x <- data.frame(height=c(50,100,60,54), sex=c("m","f","f","m"), age=c(0,2.9,0.6,0.2)) x$height.sds <- sds(value = x$height, age = x$age, sex = x$sex, male = "m", female = "f", ref = who.ref, item = "height") head(x) #+END_SRC
#+RESULTS[46a6ba3828dbb6c977bc976a6280e0b191bc02ee]: : height sex age height.sds : 1 50 m 0.0 0.06116878 : 2 100 f 2.9 1.54150151 : 3 60 f 0.6 -3.26293906 : 4 54 m 0.2 -2.82189275
*** make_percentile_tab() **** create a percentile table #+BEGIN_SRC R :session :exports both :results output library(childsds) head(tab <- make_percentile_tab(ref = nl4.ref, item = "heightM", perc = c(5,50,95), age = 1:3)) #+END_SRC
#+RESULTS: : sex age perc_05_0 perc_50_0 perc_95_0 nu mu sigma : 1 male 1 72.82291 77.15261 81.48232 1 77.15261 0.03411775 : 2 male 2 82.10371 87.67000 93.23629 1 87.67000 0.03860000 : 3 male 3 89.97701 96.28000 102.58299 1 96.28000 0.03980000 : 4 female 1 70.58366 74.89305 79.20245 1 74.89305 0.03498225 : 5 female 2 82.06492 86.76000 91.45508 1 86.76000 0.03290000 : 6 female 3 89.41744 94.83000 100.24256 1 94.83000 0.03470000
**** use the ~stack~ argument to create a dataframe in the long format for use in ggplot #+BEGIN_SRC R :session :exports both :results output library(childsds) head(tab <- make_percentile_tab(ref = nl4.ref, item = "heightM", perc = c(5,50,95), age = seq(0,20,by=0.1), stack = T)) #+END_SRC
#+RESULTS: : age sex variable value : 1 0.0 male perc_05_0 47.82905 : 2 0.1 male perc_05_0 51.65139 : 3 0.2 male perc_05_0 55.37913 : 4 0.3 male perc_05_0 58.68443 : 5 0.4 male perc_05_0 61.60275 : 6 0.5 male perc_05_0 64.21947
#+BEGIN_SRC R :session :exports both :results output graphics :file fig_1.png :height 400 :width 600 library(ggplot2) ggplot(tab, aes( x = age, y = value, group=paste(sex, variable))) + geom_line(aes(linetype = sex)) + theme_classic() + theme(legend.position = c(0.1,0.8)) #+END_SRC
#+RESULTS[9e68fab1cedee6b9007e7fe1696cac77f23d3ef4]: [[file:fig_1.png]]