cran / anthro

:exclamation: This is a read-only mirror of the CRAN R package repository. anthro — Computation of the WHO Child Growth Standards. Homepage: https://github.com/worldhealthorganization/anthro Report bugs for this package: https://github.com/worldhealthorganization/anthro/issues
0 stars 0 forks source link

na. errors when calculation z score with WHO Anthro #1

Open IsabelPotani opened 1 year ago

IsabelPotani commented 1 year ago

I get the error below when calculating z scores using WHO anthro for all time points except at baseline. It works just fine when I use a different age variable (for the first time point/baseline). My understanding was that even if you have missing data in the raw variables, it should generate missing data for the zscore calculation.

df2<-data.frame(dm_sex = c(2L, 1L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 
1L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 1L, 1L, 
2L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 2L, 2L, 
1L, 2L), age_days_wk3 = c(531, 584, 667, NA, NA, NA, NA, 206, 
267, 310, 228, 222, 544, 558, 405, NA, NA, NA, NA, NA, 363, 393, 
328, 308, 434, 342, 325, 264, NA, 264, NA, NA, NA, NA, NA, NA, 
250, -240, NA, NA, NA, NA, NA), wkly_weightwk3 = c(7.23, 8.55, 
7.44, NA, NA, NA, NA, 4.2, 6.52, 5.87, 4.22, 5.79, 7.95, 6.25, 
7.06, NA, NA, NA, NA, NA, 6.68, 6.42, 7.86, 6.16, 7.1, 5.44, 
7.4, 5.76, NA, 5.22, NA, NA, NA, NA, NA, NA, 6.83, 7.67, NA, 
NA, NA, NA, NA), ht_fwk3 = c(70.95, 79.2, 74.35, NA, NA, NA, 
NA, 59.45, 66.65, 65.25, 57.3, 61.75, 73.35, 71.9, 67.65, NA, 
NA, NA, NA, NA, 67.5, 68.45, 75.15, 68, 72, 63.2, 70.2, 62.55, 
NA, 59.45, NA, NA, NA, NA, NA, NA, 66.55, 73.05, NA, NA, NA, 
NA, NA))

anth3<- with(
  df,
  anthro_zscores(
    sex = adm_sex, age =age_days_wk3,
    weight =wkly_weightwk3, lenhei = ht_fwk3
  ))

Error in round_up(res) : all(x >= 0, na.rm = TRUE) is not TRUE

gaborcsardi commented 1 year ago

Hi, this is a read only mirror of CRAN, please see the package authors in the DESCRIPTION file. Look for Maintainer, BugReports and URL. Thanks!