From 24780530d539f5d35925618d99e29d1687ae275f Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 14 Jul 2023 15:21:43 -0400 Subject: [PATCH 1/3] Add failing test --- tests/testthat/test-simplify.R | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/testthat/test-simplify.R b/tests/testthat/test-simplify.R index a31cdfc..3bf2875 100644 --- a/tests/testthat/test-simplify.R +++ b/tests/testthat/test-simplify.R @@ -115,3 +115,20 @@ test_that("nlmixr_object_simplify_zero_initial", { new_model <- nlmixr_object_simplify_zero_initial(pheno) expect_equal(body(new_model), body(pheno_0)) }) + +test_that("re-estimating a model works with covariates (#9)", { + bad_data_lower_case <- nlmixr2data::pheno_sd + bad_data_lower_case$id <- bad_data_lower_case$ID + fit_estimated <- + suppressMessages( + nlmixr2est::nlmixr( + object = model_simple, + data = nlmixr2data::pheno_sd, + est = "focei", + control = list(eval.max = 1) + ) + ) + expect_true( + "WT" %in% names(nlmixr_data_simplify(data = nlmixr2data::pheno_sd, object = fit_estimated)) + ) +}) From 56b62b93ab44be942ac85f228cee68d22e6fdad1 Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 14 Jul 2023 15:40:16 -0400 Subject: [PATCH 2/3] Ensure that covariate columns are found for fitted objects --- R/simplify.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/simplify.R b/R/simplify.R index c39ad75..e3dace6 100644 --- a/R/simplify.R +++ b/R/simplify.R @@ -89,7 +89,12 @@ nlmixr_data_simplify <- function(data, object, table = list()) { paste0("'", nlmixr_names[mask_duplicated], "'", collapse = ", ") ) } - cov_names <- nlmixr_data_simplify_cols(data, cols = object$all.covs, type = "covariate") + if (!is.null(object$ui)) { + covVec <- object$ui$all.covs + } else { + covVec <- object$all.covs + } + cov_names <- nlmixr_data_simplify_cols(data, cols = covVec, type = "covariate") keep_names <- nlmixr_data_simplify_cols(data, cols = table$keep, type = "keep") # Simplifying the nlmixr_names column names to always be lower case ensures # that upper/lower case column name changes will not affect the need to rerun. From 22284e0e946ec207173438e4750e3b5a04fc90fe Mon Sep 17 00:00:00 2001 From: Bill Denney Date: Fri, 14 Jul 2023 16:28:57 -0400 Subject: [PATCH 3/3] Fix R cmd check issues --- .Rbuildignore | 1 + R/simplify.R | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index 8b9b94f..5ee7385 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,5 +1,6 @@ ^nlmixrtargets\.Rproj$ ^\.Rproj\.user$ +^LICENSE$ ^LICENSE\.md$ ^README\.Rmd$ ^cran-comments\.md$ diff --git a/R/simplify.R b/R/simplify.R index e3dace6..5853d9f 100644 --- a/R/simplify.R +++ b/R/simplify.R @@ -43,7 +43,7 @@ nlmixr_object_simplify_zero_initial <- function(object) { } nlmixr_object_simplify_zero_initial_helper <- function(object) { - if (rxode2:::.matchesLangTemplate(object, str2lang(".name(initial) <- ."))) { + if (rxode2::.matchesLangTemplate(object, str2lang(".name(initial) <- ."))) { object[[2]][[2]] <- 0 } else if (is.call(object)) { for (idx in seq_along(object)) {