From 6fa49ab10946c85a33db91529e39b13d110ae27a Mon Sep 17 00:00:00 2001 From: Stef van Buuren Date: Fri, 15 Mar 2024 10:48:27 +0100 Subject: [PATCH] Solves "Error in eval(predvars, data, env) : object 'hgt_z_0' not found". Added test code and dependency to chartplotter 0.32.0, resolved issue #23 --- DESCRIPTION | 2 +- renv.lock | 8 ++++---- tests/testthat/test-draw_chart.R | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 tests/testthat/test-draw_chart.R diff --git a/DESCRIPTION b/DESCRIPTION index f8993e8..5f5ed06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ Imports: bdsreader (>= 0.24.2), chartbox (>= 1.15.0), chartcatalog (>= 1.14.0), - chartplotter (>= 0.31.2), + chartplotter (>= 0.32.0), dplyr, curl, grDevices, diff --git a/renv.lock b/renv.lock index b9ab06c..e64225c 100644 --- a/renv.lock +++ b/renv.lock @@ -314,15 +314,15 @@ }, "chartplotter": { "Package": "chartplotter", - "Version": "0.31.2", + "Version": "0.32.0", "Source": "GitHub", - "RemoteType": "github", "Remotes": "growthcharts/bdsreader, growthcharts/centile, growthcharts/chartbox, growthcharts/chartcatalog, growthcharts/curvematching, growthcharts/jamesdemodata, growthcharts/nlreferences, growthcharts/donorloader", + "RemoteType": "github", "RemoteHost": "api.github.com", "RemoteRepo": "chartplotter", "RemoteUsername": "growthcharts", "RemoteRef": "HEAD", - "RemoteSha": "a385ccb95757c0c9ed84e701e076b3061318a2d3", + "RemoteSha": "cc5b0118b065f82b07529d613a83c274806ab623", "Requirements": [ "R", "brokenstick", @@ -340,7 +340,7 @@ "tidyr", "utils" ], - "Hash": "1227b55b54c2b0917ffd5de5c0044231" + "Hash": "505abf6bd969065c3ffdd3276d659439" }, "cli": { "Package": "cli", diff --git a/tests/testthat/test-draw_chart.R b/tests/testthat/test-draw_chart.R new file mode 100644 index 0000000..2bed9f8 --- /dev/null +++ b/tests/testthat/test-draw_chart.R @@ -0,0 +1,19 @@ +# curvematching problem +# Error in eval(predvars, data, env) : object 'hgt_z_0' not found + + +# the following code gave: Error in eval(predvars, data, env) : object 'hgt_z_0' not found +# chartplotter 0.32.0 resolved this error +library(jamesclient) +fn <- path.expand("~/Package/james/notes/Voorbeelddossier.txt") +js <- read_json_js(fn) +test_that("Matches do not condition on yname when there are no brokenstick estimates", { + expect_silent(james::draw_chart( + txt = js, chartcode = c(""), + selector = c("derive"), chartgrp = c("preterm"), agegrp = c("0-15m"), + sex = c("female"), etn = c("nl"), ga = 27L, side = c("hgt"), + curve_interpolation = TRUE, quiet = TRUE, dnr = c("0-2"), + lo = "4w", hi = c("14m"), nmatch = 10L, exact_sex = TRUE, + exact_ga = FALSE, show_future = FALSE, show_realized = FALSE, + draw_grob = FALSE)) +})