dewittpe / pedbp

R package for working with pediatric blood pressures based on age and height
http://www.peteredewitt.com/pedbp/
6 stars 0 forks source link

Unexpected variable values changes #18

Closed dewittpe closed 4 months ago

dewittpe commented 4 months ago

Some how, some way, calling the q_bp function can update the value of a variable that it shouldn't.

Notice here that the x$height_percentile has a different value after calling q_bp. I'm guessing this has to do with how the height percentiles are updated in the cpp code.

x <- list(age = 38, male = 1, height = NA, height_percentile = 0.8, p = 0.1, source = "martin2022", p = 0.1)
x
# $age
# [1] 38
# 
# $male
# [1] 1
# 
# $height
# [1] NA
# 
# $height_percentile
# [1] 0.8
# 
# $p
# [1] 0.1
# 
# $source
# [1] "martin2022"
# 
# $p
# [1] 0.1
q_bp(p_sbp = x$p, p_dbp = x$p, age = x$age, male = x$male, height_percentile = x$height_percentile, default_height_percentile = 0.8, source = "martin2022")
# $sbp
# [1] 81.00521
# 
# $dbp
# [1] 33.08126
x
# $age
# [1] 38
# 
# $male
# [1] 1
# 
# $height
# [1] NA
# 
# $height_percentile
# [1] 95
# 
# $p
# [1] 0.1
# 
# $source
# [1] "martin2022"
# 
# $p
# [1] 0.1