Open eatyourpeas opened 20 hours ago
You're right: the function is problematic if both ht and wt are missing in the data, and I'll look into this. If you want to work with the package now and if your data is missing wt and ht, you could always set ht to 1 and wt to equal bmi. So, data <- eg(sex=1:2, agem=120.5, ht=1LNA, wt=1LNA, bmi=c(15,20)); data; setDT(data) data[,let(wt=bmi, ht=1)] d3 <- cdcanthro(data, age=agem, wt=wt, ht=ht, bmi=bmi); d3
The results for ht and wt will be garbage, but the results for the bmi metrics will be fine. Also, note that in the creation of data, I've used 1L* to make the variables numeric. When you created 'data', the variables htc and wtc are logical.
I'll let you know if I make any progress
On Thu, Sep 26, 2024 at 6:23 PM Simon Chapman @.***> wrote:
So sorry - I hope you don't mind me raising more issues. Very much enjoying playing with your package.
I am finding if I pass only BMI values without height or weight, NA is returned.
Example
data = expand.grid(sex=1:2, agem=120.5, htc=(NA), wtc=(NA), bmic=c(15,20)); out = cdcanthro(data, age=agem, wt=wtc, ht=htc, bmi=bmic);
print(out)
and the result
sex agem htc wtc bmic bmi bmiz bmip waz wap haz hap <int> <num> <lgcl> <lgcl> <num> <num> <num> <num> <num> <num> <num> <num>1: 1 120.5 NA NA 15 NA NA NA NA NA NA NA2: 2 120.5 NA NA 15 NA NA NA NA NA NA NA3: 1 120.5 NA NA 20 NA NA NA NA NA NA NA4: 2 120.5 NA NA 20 NA NA NA NA NA NA NA p50 p95 bmip95 original_bmip original_bmiz perc_median mod_bmiz mod_waz <num> <num> <num> <num> <num> <num> <num> <num>1: NA NA NA NA NA NA NA NA2: NA NA NA NA NA NA NA NA3: NA NA NA NA NA NA NA NA4: NA NA NA NA NA NA NA NA mod_haz <num>1: NA2: NA3: NA4: NA
by contrast if I pass only heights or only weights i get results as expected, or if I pass BMIs together with heights and weights I get z scores for each measurement. Only if I pass in BMIs on their own do I get nulls.
I wondered if it were something to with this?
data$age <- data[[deparse(substitute(age))]]data$wt <- data[[deparse(substitute(wt))]]data$ht <- data[[deparse(substitute(ht))]] if ('bmi' %in% names(data)){ data$bmi <- data[[deparse(substitute(bmi))]] } else { data[,bmi:=wt/(ht/100)^2] # wt is in kg }
I am very new to R, coming really from python and web and mobile languages. Is there a difference between data$bmi and data[,bmi:=... ? I am passing in a data.table, not a data.frame and I think they are handled subtly differently?
— Reply to this email directly, view it on GitHub https://github.com/CDC-DNPAO/CDCAnthro/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY2XGPWKGTREVADDPUDXW3DZYSCOXAVCNFSM6AAAAABO56TGYWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TCNRSGIYTMMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
And 'eg' is my abbreviation for expand.grid
On Fri, Sep 27, 2024 at 9:44 AM David Freedman @.***> wrote:
You're right: the function is problematic if both ht and wt are missing in the data, and I'll look into this. If you want to work with the package now and if your data is missing wt and ht, you could always set ht to 1 and wt to equal bmi. So, data <- eg(sex=1:2, agem=120.5, ht=1LNA, wt=1LNA, bmi=c(15,20)); data; setDT(data) data[,let(wt=bmi, ht=1)] d3 <- cdcanthro(data, age=agem, wt=wt, ht=ht, bmi=bmi); d3
The results for ht and wt will be garbage, but the results for the bmi metrics will be fine. Also, note that in the creation of data, I've used 1L* to make the variables numeric. When you created 'data', the variables htc and wtc are logical.
I'll let you know if I make any progress
On Thu, Sep 26, 2024 at 6:23 PM Simon Chapman @.***> wrote:
So sorry - I hope you don't mind me raising more issues. Very much enjoying playing with your package.
I am finding if I pass only BMI values without height or weight, NA is returned.
Example
data = expand.grid(sex=1:2, agem=120.5, htc=(NA), wtc=(NA), bmic=c(15,20)); out = cdcanthro(data, age=agem, wt=wtc, ht=htc, bmi=bmic);
print(out)
and the result
sex agem htc wtc bmic bmi bmiz bmip waz wap haz hap <int> <num> <lgcl> <lgcl> <num> <num> <num> <num> <num> <num> <num> <num>1: 1 120.5 NA NA 15 NA NA NA NA NA NA NA2: 2 120.5 NA NA 15 NA NA NA NA NA NA NA3: 1 120.5 NA NA 20 NA NA NA NA NA NA NA4: 2 120.5 NA NA 20 NA NA NA NA NA NA NA p50 p95 bmip95 original_bmip original_bmiz perc_median mod_bmiz mod_waz <num> <num> <num> <num> <num> <num> <num> <num>1: NA NA NA NA NA NA NA NA2: NA NA NA NA NA NA NA NA3: NA NA NA NA NA NA NA NA4: NA NA NA NA NA NA NA NA mod_haz <num>1: NA2: NA3: NA4: NA
by contrast if I pass only heights or only weights i get results as expected, or if I pass BMIs together with heights and weights I get z scores for each measurement. Only if I pass in BMIs on their own do I get nulls.
I wondered if it were something to with this?
data$age <- data[[deparse(substitute(age))]]data$wt <- data[[deparse(substitute(wt))]]data$ht <- data[[deparse(substitute(ht))]] if ('bmi' %in% names(data)){ data$bmi <- data[[deparse(substitute(bmi))]] } else { data[,bmi:=wt/(ht/100)^2] # wt is in kg }
I am very new to R, coming really from python and web and mobile languages. Is there a difference between data$bmi and data[,bmi:=... ? I am passing in a data.table, not a data.frame and I think they are handled subtly differently?
— Reply to this email directly, view it on GitHub https://github.com/CDC-DNPAO/CDCAnthro/issues/10, or unsubscribe https://github.com/notifications/unsubscribe-auth/AY2XGPWKGTREVADDPUDXW3DZYSCOXAVCNFSM6AAAAABO56TGYWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2TCNRSGIYTMMA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
So sorry - I hope you don't mind me raising more issues. Very much enjoying playing with your package.
I am finding if I pass only BMI values without height or weight, NA is returned.
Example
and the result
by contrast if I pass only heights or only weights i get results as expected, or if I pass BMIs together with heights and weights I get z scores for each measurement. Only if I pass in BMIs on their own do I get nulls.
I wondered if it were something to with this?
I am very new to R, coming really from python and web and mobile languages. Is there a difference between
data$bmi
anddata[,bmi:=...
? I am passing in adata.table
, not adata.frame
and I think they are handled subtly differently?