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 6c10391..5853d9f 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. 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)) + ) +})