WorldHealthOrganization / anthro

Computation of the WHO Child Growth Standards
https://worldhealthorganization.github.io/anthro/
GNU General Public License v3.0
29 stars 9 forks source link

outputting z scores and flags in original dataframe #32

Closed pgupta919 closed 4 years ago

pgupta919 commented 4 years ago

Hi Dirk,

I am a doctoral student at Emory University using the anthro R package you developed- THANK YOU! It’s amazing and so much shorter than the SAS macro!

I was wondering however, the anthro package differs from the SAS macro as it exports the z scores and flags to a dataframe separate from the input dataset. I was wondering how the output values can be merged back in to the original file? I am not sure what the unique identifier is between the original dataframe and the dataframe with the z scores. Any help you could provide on this would be greatly appreciated!

I look forward to hearing from you and thanks again for this package!

dirkschumacher commented 4 years ago

The results of anthro_zscores are returned in the same order as your input them. So you could use the function cbind to bind the results to you original dataset. Hope this helps.

E.g.

your_data_set <- read.csv("my_survey.csv")
scores <- with(
  your_data_set,
  anthro_zscores(
    sex = sex, age = age_in_days,
    weight = weight, lenhei = lenhei
  )
)
cbind(your_data_set, scores)
pgupta919 commented 4 years ago

Thank you!